Results 1 to 2 of 2
  1. #1
    jellybeannn is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    5

    access search open new form

    hi everyone,

    i want to create a search option in an access form, the user selects a field from a dropdown(cboSearchField) and enters text into a textbox(txtSearchString). At the moment nothing happens when the button is pressed, but I would like the form(frmCustomers) to open with the search result.

    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_frmCustomers.RecordSource = "select * from Customers where " & GCriteria
    Form_frmCustomers.Caption = "Customers (" & cboSearchField.Value & " contains '*" & txtSearchString & "*')"

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

    'MsgBox "Results have been filtered."

    End If


    ** Any help please!!

  2. #2
    Datagopherdan is offline Competent Performer
    Windows 7 Access 2007
    Join Date
    Dec 2008
    Posts
    220
    Are you just trying to filter on a single field? If so, you can just use a filter on the form.

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

Similar Threads

  1. Replies: 0
    Last Post: 05-07-2010, 04:53 AM
  2. Replies: 3
    Last Post: 01-14-2010, 08:32 AM
  3. search,view and open function
    By blurboy84 in forum Reports
    Replies: 0
    Last Post: 10-08-2009, 11:42 PM
  4. Replies: 1
    Last Post: 06-02-2009, 04:29 PM
  5. Replies: 0
    Last Post: 10-16-2008, 02:39 PM

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