multiple stLinkCriteria

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
 
B

Brian Bastl

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
 
J

jon.howitt

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
 
B

Brian Bastl

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

Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top