Search Form to be empty on load (1 Viewer)

Holly_Associated

Registered User.
Local time
Today, 23:24
Joined
Mar 21, 2013
Messages
53
Hi Experts!
I have a form which is for searching for and then viewing a record based on a text box and pressing enter. This is working fine. My ID field is 4 digits and when I change the 4 digits and press enter it shows me the details for the record in all of the other boxes:

Private Sub txtJobID_AfterUpdate()
If (txtJobID & vbNullString) = vbNullString Then Exit Sub
Dim rs As DAO.Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[JobID]=""" & txtJobID & """"
If rs.NoMatch Then
MsgBox "Sorry, no such record '" & txtJobID & "' was found.", _
vbOKOnly + vbInformation
Else
Me.Recordset.Bookmark = rs.Bookmark
End If
rs.Close
txtGoTo = Null

End Sub

My question is, as this is not a data entry / additions / deletions form (I have editing and filters to yes though) How do I get it to load empty? Not on a new or blank record but empty until I have typed my 4 digits.
Just to clarify, my txtJobID box is empty on load but all of the other fields show the first record.

Any help much appreciated :confused:
 

James Dudden

Access VBA Developer
Local time
Today, 23:24
Joined
Aug 11, 2008
Messages
369
One way would be to have all your search boxes in the form header and then the rest in the detail. Then you can just hide the detail as default when the form opens and then unhide it after the user has searched.
 

Holly_Associated

Registered User.
Local time
Today, 23:24
Joined
Mar 21, 2013
Messages
53
Hi James,
Thank you for your suggestion but I found a workaround. I changed the first record in the table to 0000 and left all of the other fields blank... Hey Presto, when the form loads all of the boxes are blank and I can type in my JobID :)

I don't know how to change this to solved?
 

James Dudden

Access VBA Developer
Local time
Today, 23:24
Joined
Aug 11, 2008
Messages
369
Glad you found a solution - just be careful not to type into the first record and I'm sure it will work well.

Re setting the thread to solved I think there is a 'Thread Tools' link at the top which has this option in.
 

Users who are viewing this thread

Top Bottom