SEARCH button code

Cindy

Registered User.
Local time
Today, 11:40
Joined
Jul 3, 2014
Messages
160
I tried to adapt John Big Booty's code but it didn't work for me.

I have the below code in the OnChange event of my search box. It uses a continuous subform to search the database. It searches as I type and double clicking on the record populates the main form. Before I complete typing in the text, the record comes up because my test database is small. However in the live environment, the database will consist of huge historical data. The SEARCH button beside it is redundant but I want to reuse the code and ADD the functionality of the button to the form. How can I modify this for the button please?

main form - ObstetricsForm
sub form - ObstetricSubform
search box - cmdSRCHBOX
search button - cmdSRCHBTN
fields: [TripID], [PatientID]

If Len(cmdSRCHBOX.Text & vbNullString) = 0 Then
ObstetricSubform.Form.Filter = vbNullString
ObstetricSubform.Form.FilterOn = False
Else
ObstetricSubform.Form.Filter = "[TripID] Like '*" & cmdSRCHBOX.Text & "*' OR [PatientID] Like '*" & cmdSRCHBOX.Text & "*'"
ObstetricSubform.Form.FilterOn = True
End If
End With
 
Any reason you couldn't copy this exact code to a button's OnClick event?
 
Hi tad0075. I did but it gave me an error which I have only just figured out. I removed the ".Text" and replaced it with ".value". Thanks to you.
 

Users who are viewing this thread

Back
Top Bottom