![]() |
HELP: Syntax error (missing operator) Query Expression
Hi All, I am gettin a Syntax error (missing operator) Query Expression
'Student_Name = JAMES JAMES' on this line: Set rst = conn.Execute(strSQL) Basically, I want to pull details from access into userform fields based on what I enter in StudentName text field, Here is the code for that event: Private Sub StudentName_Change() Dim conn As Object, rst As Object, strSQL As String Set conn = CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _ "Data Source=C:\My Documents\Student_Data.accdb;" & _ "Jet OLEDB:Database Password=students;" strSQL = "SELECT Student_Number, Student_Email, Student_Phone, Student_Location" & _ " FROM Student_Table WHERE Student_Name = " & Trim(Me.StudentName.Value) Set rst = conn.Execute(strSQL) '<------- ERROR in this line Thanks in advance |
HELP: Syntax error (missing operator) Query Expression
This worked out great!
Thanks mike "Mike" wrote: Try this " FROM Student_Table WHERE Student_Name = '" & Trim(Me.StudentName.Value) & "'" "sam" wrote: Hi All, I am gettin a Syntax error (missing operator) Query Expression 'Student_Name = JAMES JAMES' on this line: Set rst = conn.Execute(strSQL) Basically, I want to pull details from access into userform fields based on what I enter in StudentName text field, Here is the code for that event: Private Sub StudentName_Change() Dim conn As Object, rst As Object, strSQL As String Set conn = CreateObject("ADODB.Connection") conn.Open "Provider=Microsoft.ACE.OLEDB.12.0; " & _ "Data Source=C:\My Documents\Student_Data.accdb;" & _ "Jet OLEDB:Database Password=students;" strSQL = "SELECT Student_Number, Student_Email, Student_Phone, Student_Location" & _ " FROM Student_Table WHERE Student_Name = " & Trim(Me.StudentName.Value) Set rst = conn.Execute(strSQL) '<------- ERROR in this line Thanks in advance |
All times are GMT +1. The time now is 01:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com