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
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