Search Form Query

Dee Cee

New member
Local time
Today, 00:49
Joined
Jun 11, 2008
Messages
8
I have a search form with a number of comboboxes. The user can select any option from as many comboboxes as they please to find the record(s) they want to track. It works fine on the first open - opens blank. It also works fine if you open, choose an option, but close the form. When you reopen the form all comboboxes are blank. My problem is this:

After a user has run a search and looked at the records they may want to run another search. If they ask for the same form again from the switchboard it opens with their previous choices.

This is the code I have:

Private Sub OK_Click()
On Error GoTo Err_Command0_Click
Me.Visible = False
DoCmd.OpenForm "TPF", acViewNormal, acEdit
DoCmd.Close acForm, "Search"
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
If Err <> 2501 Then
MsgBox Err.Description
End If
Resume Exit_Command0_Click
End Sub

I am guessing I need to insert a command to clear each individual combobox after the open form cmd and before the close form cmd. Would this involve seperate sub commands for each one?

I am thinking of something like this

Private Sub cmdClearCombo1_Click()
With Me.TPTrust
.Value = Null
End With
End Sub

How would I insert a command to run that in the middle of the code. Also, will I need to give focus back to my search form rather than my search results form?
 
I usually add a Clear button to my complex search forms. In the click event of the Clear button, I clear all the combos, etc.
 
Ive sorted it now, turned out to be an idiot mistake by me.

I changed the name of the search form from 'Search' and never changed the code to reflect that. When I ran the search it left the form open in the background and just pulled it forward for the next search.

Thanks for the help anyway Pat
 

Users who are viewing this thread

Back
Top Bottom