Runtime Error '3131'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • babyspring
    New Member
    • Dec 2006
    • 4

    #1

    Runtime Error '3131'

    Hi All,

    I have encountered an annoying problem. I've read through all the post concerning this error. But yet, I still can't seem to solve the problem. When I run the program, it pops out this annoying error stating Run-time error '3131'. Syntax error in FROM clause. I've also read through salman1karim's post, and added spaces after and before a new line like told. And yet, it can't seem to solve the problem... Can anyone please help me? I'm very new to VB so, I might miss out something obvious...

    Code:

    Code:
    Private Sub txtSearch_Change()
    
    If txtSearch.Text = vbNullString Then
        Set rstSearch = dbsNormah.OpenRecordset("Children General Record", dbOpenTable)
     Else
       Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where Full Name = '" & txtSearch.Text & "' " & " & '*'")
       End If
        list
         End Sub
    
    Private Sub lstdata_Click()
         Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where full name = '" & Trim(lstdata.list(lstdata.ListIndex)) & "'")
         
          rstSearch.MoveFirst
          LblFullNameR.Caption = rstSearch("Full Name")
          LblSurnameR.Caption = rstSearch("Surname")
          LblICR.Caption = rstSearch("Identification")
          LblTelR.Caption = rstSearch("Tel No")
          LblSchoolR.Caption = rstSearch("School")
          LblIDR.Caption = rstSearch("Patient ID")
    Thank you very much...
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by babyspring
    Hi All,

    I have encountered an annoying problem. I've read through all the post concerning this error. But yet, I still can't seem to solve the problem. When I run the program, it pops out this annoying error stating Run-time error '3131'. Syntax error in FROM clause. I've also read through salman1karim's post, and added spaces after and before a new line like told. And yet, it can't seem to solve the problem... Can anyone please help me? I'm very new to VB so, I might miss out something obvious...

    Code:

    Code:
    Private Sub txtSearch_Change()
    
    If txtSearch.Text = vbNullString Then
        Set rstSearch = dbsNormah.OpenRecordset("Children General Record", dbOpenTable)
     Else
       Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where Full Name = '" & txtSearch.Text & "' " & " & '*'")
       End If
        list
         End Sub
    
    Private Sub lstdata_Click()
         Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where full name = '" & Trim(lstdata.list(lstdata.ListIndex)) & "'")
         
          rstSearch.MoveFirst
          LblFullNameR.Caption = rstSearch("Full Name")
          LblSurnameR.Caption = rstSearch("Surname")
          LblICR.Caption = rstSearch("Identification")
          LblTelR.Caption = rstSearch("Tel No")
          LblSchoolR.Caption = rstSearch("School")
          LblIDR.Caption = rstSearch("Patient ID")
    Thank you very much...
    Hi you have to enclose the table name and field name in square brackets because it will not be recognised as a single name:

    Code:
    Set rstSearch = dbsNormah.OpenRecordset("Select * from [Children General Record] where [full name] = '" & Trim(lstdata.list(lstdata.ListIndex)) & "'")

    Comment

    • babyspring
      New Member
      • Dec 2006
      • 4

      #3
      Thank you very much!

      Comment

      • willakawill
        Top Contributor
        • Oct 2006
        • 1646

        #4
        Originally posted by babyspring
        Thank you very much!
        welcome very much :)

        Comment

        Working...