How do I refresh the data on a form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i have 2 dropdown menus that came from combo boxes. when an item in the
dropdown is clicked it will automatically run a query. When i open the form
the data shown is blank until the arrow is clicked. That is how I want it to
be however, I need to be able to hit a refresh button or not hit a button at
all and have the dropdowns go back to a blank field after an item has been
selected.
 
It's a little difficult answering the question without knowing whether these
are bound or unbound controls. However, in general, you can just put this VBA
code:

Private Button1_Click()
Combo2 = Null
Combo3 = Null
'etc.
End Sub

You could also just put the above code into the Combo1_AfterUpdate if you
want Combo2 & Combo3 to be null again after an item is selected in Combo1.
 
One combo box is called Trading Name and the other is Rep Name.
What would be the code needed to allow both fields to return to blank after
an item is selected on one of the boxes?
 
You said that when an item is clicked, it automatically runs a query. How are
you calling the query? I assume that somewhere in your VBA (probably in
TradingName_AfterUpdate and/or RepName_AfterUpdate) there is a DoCmd.Open
Query... statement. If so, just put this on the next two lines after the
query runs (if it runs from two places, just put both these lines in both
places):

TradingName = Null
RepName = Null

They key is to set the values to null after you run the query, so if you are
calling the query some other way, re-post so that we can find out where to
put these two lines.
 
It is impossible for me to add lines in code because everytime i run anything
from VBA i recieve a compile error in the DB. So everything that I have
running is done off of Macros. The query values are TradingName and CSG Rep
Surname
 
Hmmm... I kinda bypassed macro training & went straight to VBA. I just made
it work, though. Right after the OpenQuery line in your macro make a SetValue
action for each of the two boxes, like this:

Item: [Forms]![YourForm]![TradingName]
Expression: = Null
 
Back
Top