Log in

View Full Version : Forms - button code


Sheba2014
Aug 5, 2014, 12:33 PM
Hi Scott, I have the below code in the OnChange event of my search box. It uses a subform to search the database. It searches as I type and double clicking on the record will populate the main form therefore making the SEARCH button beside it redundant. I don't want to get rid of the button for aesthetic reasons and also because right now, my database is small so before I complete typing in the text the record comes up but in the live environment, the database will consist of huge historical data. I want to reuse the code and ADD the functionality of the button to the form. How can I modify the ELSE part for the button please? Currently, it has no code

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