By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,573 Members | 3,008 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,573 IT Pros & Developers. It's quick & easy.

Runtime Error '3131'

P: 4
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtSearch_Change()
  2.  
  3. If txtSearch.Text = vbNullString Then
  4.     Set rstSearch = dbsNormah.OpenRecordset("Children General Record", dbOpenTable)
  5.  Else
  6.    Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where Full Name = '" & txtSearch.Text & "' " & " & '*'")
  7.    End If
  8.     list
  9.      End Sub
  10.  
  11. Private Sub lstdata_Click()
  12.      Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where full name = '" & Trim(lstdata.list(lstdata.ListIndex)) & "'")
  13.  
  14.       rstSearch.MoveFirst
  15.       LblFullNameR.Caption = rstSearch("Full Name")
  16.       LblSurnameR.Caption = rstSearch("Surname")
  17.       LblICR.Caption = rstSearch("Identification")
  18.       LblTelR.Caption = rstSearch("Tel No")
  19.       LblSchoolR.Caption = rstSearch("School")
  20.       LblIDR.Caption = rstSearch("Patient ID")
  21.  
Thank you very much...
Dec 9 '06 #1
Share this Question
Share on Google+
3 Replies


100+
P: 1,646
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:

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtSearch_Change()
  2.  
  3. If txtSearch.Text = vbNullString Then
  4.     Set rstSearch = dbsNormah.OpenRecordset("Children General Record", dbOpenTable)
  5.  Else
  6.    Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where Full Name = '" & txtSearch.Text & "' " & " & '*'")
  7.    End If
  8.     list
  9.      End Sub
  10.  
  11. Private Sub lstdata_Click()
  12.      Set rstSearch = dbsNormah.OpenRecordset("Select * from Children General Record where full name = '" & Trim(lstdata.list(lstdata.ListIndex)) & "'")
  13.  
  14.       rstSearch.MoveFirst
  15.       LblFullNameR.Caption = rstSearch("Full Name")
  16.       LblSurnameR.Caption = rstSearch("Surname")
  17.       LblICR.Caption = rstSearch("Identification")
  18.       LblTelR.Caption = rstSearch("Tel No")
  19.       LblSchoolR.Caption = rstSearch("School")
  20.       LblIDR.Caption = rstSearch("Patient ID")
  21.  
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:

Expand|Select|Wrap|Line Numbers
  1. Set rstSearch = dbsNormah.OpenRecordset("Select * from [Children General Record] where [full name] = '" & Trim(lstdata.list(lstdata.ListIndex)) & "'")
Dec 9 '06 #2

P: 4
Thank you very much!
Dec 10 '06 #3

100+
P: 1,646
Thank you very much!
welcome very much :)
Dec 10 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.