multiple stLinkCriteria

  • Thread starter Thread starter jon.howitt
  • Start date Start date
J

jon.howitt

I get the following error message when trying to execute this form

Syntax error (missing operator) in query '[Function]= xxx AND
[Caseref]=yyy'.

Heres the code I can't find what's wrong with it.

Option Compare Database

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

Set rs = Me.Recordset.Clone
rs.FindFirst "[ID] = " & Str(Nz(Me![Function], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub



Private Sub OpenNew_Click()
On Error GoTo Err_OpenNew_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Issues_change"
stLinkCriteria = "[Function]=" & Me![Function]
stLinkCriteria = stLinkCriteria & " AND [Caseref]=" & Me![Caseref]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenNew_Click:
Exit Sub

Err_OpenNew_Click:
MsgBox Err.Description
Resume Exit_OpenNew_Click

End Sub


Any assistance would be Greatly appreciated.

Cheers
Jon_H
 
jon,

Function is a reserved word. Change the control name and any table
fieldnames to something else. That may be all that's required.

Brian
 
fixed with this.

Private Sub OpenNew_Click()
On Error GoTo Err_OpenNew_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Issues_change"

stLinkCriteria = "[Function]=" & "'" & Me![Function] & "'"
stLinkCriteria = stLinkCriteria & "AND [Caseref]=" & "'" &
Me![Caseref] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_OpenNew_Click:
Exit Sub
 
Very good. Glad you got it to work. But using reserved words is never a good
idea.

Brian
 
Back
Top