Run-time error 3067 (1 Viewer)

The_Vicar75

Registered User.
Local time
Today, 07:40
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
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:40
Joined
Aug 30, 2003
Messages
36,124
The form references need to be concatenated in:

"...Between (#" & [forms].[frm_Afsluiting].[txt_begindatum] & "# And #" & [forms].[frm_Afsluiting].[txt_einddatum] & "#...
 

The_Vicar75

Registered User.
Local time
Today, 07:40
Joined
Apr 22, 2008
Messages
13
Thx pbaldy! That sure was the solution, thank you!

V.
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 22:40
Joined
Aug 30, 2003
Messages
36,124
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

Top Bottom