Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Access (https://www.askmehelpdesk.com/forumdisplay.php?f=441)
-   -   Forms - button code (https://www.askmehelpdesk.com/showthread.php?t=798503)

  • Aug 5, 2014, 12:33 PM
    Sheba2014
    Forms - button code
    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

  • All times are GMT -7. The time now is 11:18 AM.