Combo Box Syntax Error

  • Thread starter Thread starter mikael
  • Start date Start date
M

mikael

Guest
I am trying to use a combo box to select a specific schedule for a specific
student, and then load that schedule onto the form.

My combobox is populated with this query:
SELECT tblSchedules.term FROM tblSchedules WHERE
(((tblSchedules.userName)=txtUserName));

The WHERE clause is avoiding seeing every single "term" record, only the
ones pertaining to the specific user.

When I run this, I got an error saying:
Run-time error '3077'
Sytax error (missing operator) in expression.

Here is the code for the combo box: (created by a wizard)

Private Sub Combo72_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[term] = ' " & Me![Combo72] & " ' "
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub

The error is dealing with the line: "rs.FindFirst...."

Any help would be greatly appreciated!
 
Last edited:
ditto

I have exactly the same error with exactly the same bit of code. To make matters worse, I have similar code elsewhere in my project and it works perfectly, and I cannot find a reasonable difference between the 2 sets of code, which would explain the error message.

Not working code
___________________________________________________________
Private Sub Combo31_AfterUpdate()
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[TenantPPS] = " & Combo31.Value
If rs.EOF Then
MsgBox "Tenant Not Found"
Else
Me.Bookmark = rs.Bookmark
End If
rs.Close
End Sub

Working Code
_______________________________________________
Private Sub Combo26_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[AgtID] = " & Str(Me![Combo26])
Me.Bookmark = rs.Bookmark
End Sub
____________________________________________________
Believe me I have tried just about every combination to know avail
 
Is TenantPPS text and AgtID a number? That would explain why one works and not the other.

Change
Code:
rs.FindFirst "[TenantPPS] = " & Combo31
to
Code:
rs.FindFirst "[TenantPPS] = '" & Combo31 & "'"
and it should work.

P.S. You don't need .Value as that is the default
 
You were perfectly right. I used the extra quotes and it worked! Thanks very much.
 

Users who are viewing this thread

Back
Top Bottom