Refresh Form

84hickman

New Member
Joined
Mar 18, 2010
Messages
17
I have a form with 4 listboxes and a command button. The command button runs a macro that runs a query using the list boxes as parameters. If no value is chosen in a list box, records with any value in that field are returned. This all works great.

I'd like the users choices to clear after the query runs or clear after clicking a "Clear Choices" command button on the search form.

This seems like it should be fairly simple... but I can't seem to get it working.




Thanks!
 
Last edited:

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
What sort of query is it?

If it's just a select query used to show data based on criteria from the form then you shouldn't need to use a macro to 'run' it.
 
Upvote 0
I don't need the macro to run the query; I know that.
This database is used my people who know NOTHING about Access. Everything must be dummy and fool proof. Thus the buttons and forms.

Everything works perfectly... I just do not want users to have to close and reopen the form to search by new parameters.
 
Upvote 0
So what is it you actually want to do?

You could just reset the form by closing and opening it again.

If it was a bound form, eg based on a table or query, you could perhaps use Requery.
 
Upvote 0
I want the form to automatically clear the listboxes of choices either after displaying the query results or upon clicking a new command button.

The form is not based on a table or query.
 
Upvote 0
Set each combo to "" like this
Code:
MyCombo1.Value = ""
MyCombo2.Value = ""
MyCombo3.Value = ""
MyCombo4.Value = ""

hth

Rich
 
Upvote 0
That LOOKS like it works... It clears the highlights from the previous choices.

However, when I pick new choices and try to run the query through the command button again I get an error message.

"The expression is typed incorrectly, or it is too complex to be evaluated....."
 
Upvote 0
This will close the form and reopen it with all the controls set to their default values.

Code:
Private Sub Command6_Click()
Dim strFormName As String
 
    strFormName = Me.Name
    
    DoCmd.Close acForm, strFormName
    
    DoCmd.OpenForm strFormName
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,222,830
Messages
6,168,509
Members
452,194
Latest member
Lowie27

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top