Results 1 to 2 of 2
  1. #1
    injanib is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Jan 2011
    Posts
    67

    Search Button

    I have the following code that works perfect on another form where the criteria fields are text data type. On this form, the StudentName is a text field and ClassID is a number field. I keep getting Run-Time Error '3075' Missing operator in Query Expression. Can someone tell me why I get this error on this form.

    Private Sub cmdSearch_Click()
    Dim strFilter As String
    Dim intRecordCount As Integer



    If (Len(txtSearchStudentName) & "") > 0 Then strFilter = "[StudentName]='" & txtSearchStudentName & "'"

    If (Len(txtSearchClass) & "") > 0 Then
    If Len(strFilter) > 0 Then strFilter = strFilter & " And "
    strFilter = strFilter & "[ClassID]=" & txtSearchClass & ""

    End If

    If DCount("*", "tblRegistration", strFilter) = 0 Then
    MsgBox "No record found.", vbInformation + vbOKOnly, "No Record Found!"

    Else
    intRecordCount = DCount("*", "tblRegistration", strFilter)
    MsgBox intRecordCount & " record(s) found.", vbInformation + vbOKOnly, "Records Found!"

    Me.Filter = strFilter
    Me.FilterOn = True
    End If

    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Change this line:
    strFilter = strFilter & "[ClassID]=" & txtSearchClass & ""
    ...to...
    strFilter = strFilter & "[ClassID]=" & txtSearchClass

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

Similar Threads

  1. Search Button with Multiple Criteria
    By injanib in forum Forms
    Replies: 2
    Last Post: 01-12-2011, 02:21 AM
  2. search button on Form
    By josejuancruz in forum Access
    Replies: 1
    Last Post: 12-23-2010, 07:21 PM
  3. Replies: 3
    Last Post: 01-14-2010, 08:32 AM
  4. program find button to search whole table
    By sammer021486 in forum Programming
    Replies: 2
    Last Post: 10-01-2009, 06:36 AM
  5. Search and Clear button
    By polk383 in forum Programming
    Replies: 1
    Last Post: 08-30-2006, 08:51 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