Results 1 to 4 of 4
  1. #1
    jbone is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    8

    Exclamation VBA code wont execute properly - kinda buggy

    Hello Everyone,



    it is never easy to explain these situations but I am going to do my best.

    I have a situation where I want to update records in a table via a form. The form I created is query based and so it finds me the records based on the criteria [which is,in my case, Text15 Value]. This query form is in a main form- so essentially is a subform and I toggle between forms using a side bar I created. I use the 'make visible' code to bring up the form.
    When I run the query by searching a in the text field [text 15 - criteria] it brings up records (highlighted in yellow in the picture).

    if 'Number of inadequate responses' field is blank as well as 'Resolution Date' field I want to make the below (circled in black in the picture) visible so the user can Update their record BUT if it is not blank (say they re-search their Case Number again) I want it to not be visible - so they cant override their initial submission.

    Just to add some context to the Submit Button will update the record in the table (field inadequate responses' & 'Resolution Date') and make the below (circled in black in the picture) not visible as well. I dont know how to refresh the whole subform to start over again - Ive tried a million things.

    Here is my code for the if statement

    If IsNull(Me.number_of_inadequate_response.Value) Then
    Me.Combo30.Visible = True
    Me.Text21.Visible = True
    Me.Text23.Visible = True
    Else
    Me.Combo30.Visible = False
    Me.Text21.Visible = False
    Me.Text23.Visible = False
    Me.Combo30.Value = ""
    Me.Text23.Value = ""
    Me.Text21.Value = ""
    End If
    Attached Thumbnails Attached Thumbnails foraccessform.PNG  

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    To make your code easier to debug, do the following:

    1. Put Option Explicit at the top of the module, just below Option Compare Database
    2. give all your controls and variables meaningful names
    3. use indentation in your code so it is easier to read (certainly for people who are not familiar with your code)

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    addendum - consider using conditional formatting - you can't hide controls, but you can disable them. If the control is on a subform and the condition is based on a value on the main form, use the parent predicate to reference it e.g.

    expression is....isnull(parent.controlname)

  4. #4
    jbone is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2015
    Posts
    8
    Thanks for your reply Ajax. I had figured something out by re-positioning the code

Please reply to this thread with any new information or opinions.

Similar Threads

  1. vba code help - Currentdb.execute
    By joycesolomon in forum Programming
    Replies: 5
    Last Post: 08-11-2014, 11:25 AM
  2. Replies: 4
    Last Post: 11-30-2012, 03:09 PM
  3. execute code on subform without adding a record
    By markjkubicki in forum Forms
    Replies: 5
    Last Post: 10-13-2011, 12:23 PM
  4. How to execute Line of Code
    By jo15765 in forum Programming
    Replies: 4
    Last Post: 06-22-2011, 05:37 PM
  5. Can't get any of my code to execute!
    By blacksaibot in forum Programming
    Replies: 4
    Last Post: 03-16-2010, 08:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums