Results 1 to 4 of 4
  1. #1
    cysklement is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Posts
    15

    search record if found open form.

    Hi,

    I need help with creating a just form that has an unbound textbox and a button for search record. For instance if the user enter the criteria in the textbox and the item matches the criteria in the search textbox. it will open up the form. it's like google website.......
    Help pls.



    thanks

  2. #2
    cysklement is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Posts
    15
    Hi I had found this coding but I just can't make it work to openform if records found...

    Private Sub cmdSearch_Click()

    If Len(cboSearchField) = 0 Or IsNull(cboSearchField) = True Then
    MsgBox "You must select a field to search."

    ElseIf Len(txtSearchString) = 0 Or IsNull(txtSearchString) = True Then
    MsgBox "You must enter a search string."

    Else

    'Generate search criteria
    GCriteria = cboSearchField.Value & " LIKE '*" & txtSearchString & "*'"

    'Filter frmCustomers based on search criteria
    Form_frmmultifunctionprinter.RecordSource = "select * from tblmultifunctionprinter where " & GCriteria
    Form_frmmultifunctionprinter.Caption = "tblmultifunctionprinter (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"

    'Close frmSearch
    DoCmd.Close acForm, "frmSearch"
    DoCmd.OpenForm acForm, "frmmachine"

    MsgBox "Results have been filtered."

    End If

    End Sub

    I added the code DoCmd.OpenForm acForm, "frmmachine"
    but it seems doesn't work

    Help pls.

  3. #3
    cysklement is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2013
    Posts
    15
    Hi I have encountered a problem. even the value is not accurate in the search box it will just pop up my form....
    How do I make it as if the value entered in the search box in not in the db it will show a msg box...?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    You could use a DCount() with your criteria variable. Pop your message box if the result is zero.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 12-22-2014, 01:57 PM
  2. The search key was not found in any record
    By virtualprg in forum Import/Export Data
    Replies: 46
    Last Post: 08-26-2014, 10:51 AM
  3. Search key was not found in any record.
    By mgio in forum Access
    Replies: 2
    Last Post: 08-05-2014, 01:32 PM
  4. Replies: 7
    Last Post: 04-17-2013, 04:33 PM
  5. Replies: 10
    Last Post: 03-28-2011, 08:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums