Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003

    Unanswered: Help with VBA in mS Access.

    Hi, I'm trying to put this code into a command button so when the user enters any name in a text box called txtFind the person or persons with this name will appear in the fields labeled FirstName, LastName and Address on the form called frmInfo, heres the codes I used:

    Dim strSQl as String

    strSQL = "SELECT * FROM tblInfo "
    strSQL = strSQL & "WHERE FirstName Like ""*"
    strSQL = strSQL & Forms!frmInfo.txtFind.Value
    strSQL = strSQL & "*"";"

  2. #2
    Join Date
    Jul 2003
    One way to do it is to have the form display all of the records when opened, (assuming the form is bound to the table).

    In the command buttons OnClick event, put the following code:

    Forms!frmInfo.Filter ="[FirstName] like ""*" & Forms!frmInfo.txtFind.Value & "*"""
    Forms!frmInfo.FilterOn = True

    You may have to tweak the number of " in the syntax to get it to work.

    There's a different way to do it if you're using an unbound form.
    In that case, you'll need the entire SQL statement you have below,
    plus some more code. Let me know if this is what you're doing.

    Inspiration Through Fermentation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts