Run-time error 3067

The_Vicar75

Registered User.
Local time
Today, 22:54
Joined
Apr 22, 2008
Messages
13
Hi,

This works fine in a query, but if I use it behind a commandbutton in VBA error 3067 occurs.
I tried spaces at begin & end of the strings, but it doesn't help much.

anyone?

thx,
V.

SQL:
Private Sub Vette_Test_Kopij_Tblmkqry()
Dim SQLstringTEST As String
DoCmd.SetWarnings False

SQLstringTEST = " SELECT tblOverview.NcNumber, tblOverview.IssueDate, tblOverview.NonConformity, tblOverview.lkpStatus, tblOverview.ClosingDate, tblOverview.Feedback, [forms].[frm_Afsluiting].[txt_begindatum] AS Begindatum, [forms].[frm_Afsluiting].[txt_einddatum] AS Einddatum INTO tbl_Vette Test " & _
" FROM tblOverview " & _
" WHERE (((tblOverview.IssueDate) Between ([forms].[frm_Afsluiting].[txt_begindatum] And [forms].[frm_Afsluiting].[txt_einddatum])) AND ((tblOverview.lkpStatus)='open' Or (tblOverview.lkpStatus)='follow-up') AND ((tblOverview.ClosingDate) Is Null)) " & _
" ORDER BY tblOverview.IssueDate; "

Debug.Print SQLstringTEST

DoCmd.RunSQL SQLstringTEST
DoCmd.SetWarnings True
End Sub
 
The form references need to be concatenated in:

"...Between (#" & [forms].[frm_Afsluiting].[txt_begindatum] & "# And #" & [forms].[frm_Afsluiting].[txt_einddatum] & "#...
 
Thx pbaldy! That sure was the solution, thank you!

V.
 
Did you notice what the first poster said about spaces?

Edit: Poster "TheGame7" posted some SQL that didn't have proper spacing. For some reason they deleted their post.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom