Okay, your query appears to have 2 parameters: bdate and edate. You need to
supply those programmatically, or else concatenate the values into a string
and execute that.
This example assumes you put this code into a form that has 2 unbound text
boxes named bdate and edate. The code builds the dates from the form into
the string, so the code does not need the saved query at all.
Dim strSql As String
Const conJetDate = "\#mm\/dd\/yyyy\#"
strSql = "INSERT INTO newcases ( EntryDate, ClientNumber, MatterNumber,
MatterAcceptedDate, BusinessNamesOnly, LastName, FirstName, MiddleInitial,
ATTYInitials, PracticeClass ) " & _
"SELECT NewClientCaseMasterTable.EntryDate,
NewClientCaseMasterTable.ClientNumber,
NewClientCaseMasterTable.MatterNumber,
NewClientCaseMasterTable.MatterAcceptedDate,
NewClientCaseMasterTable.BusinessNamesOnly,
NewClientCaseMasterTable.LastName, NewClientCaseMasterTable.FirstName,
NewClientCaseMasterTable.MiddleInitial,
NewClientCaseMasterTable.ATTYInitials,
NewClientCaseMasterTable.PracticeClass, * " & _
"FROM NewClientCaseMasterTable WHERE NewClientCaseMasterTable.EntryDate
Between " & _
Format(Me.bdate, conJetDate) & " And " & Format(Me.edate, conJetDate) & ";"
dbEngine(0)(0).Execute strSql, dbFailOnError
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Reply to group, rather than allenbrowne at mvps dot org.
Darryl said:
here is the query :
INSERT INTO newcases ( EntryDate, ClientNumber, MatterNumber,
MatterAcceptedDate, BusinessNamesOnly, LastName, FirstName, MiddleInitial,
ATTYInitials, PracticeClass )
SELECT NewClientCaseMasterTable.EntryDate,
NewClientCaseMasterTable.ClientNumber,
NewClientCaseMasterTable.MatterNumber,
NewClientCaseMasterTable.MatterAcceptedDate,
NewClientCaseMasterTable.BusinessNamesOnly,
NewClientCaseMasterTable.LastName, NewClientCaseMasterTable.FirstName,
NewClientCaseMasterTable.MiddleInitial,
NewClientCaseMasterTable.ATTYInitials,
NewClientCaseMasterTable.PracticeClass, *
FROM NewClientCaseMasterTable
WHERE (((NewClientCaseMasterTable.EntryDate) Between [bdate] And
[edate]));
The query prompts for [bdate] and [edate].
Allen Browne said:
Does your query contain references to a text box on a form? The
Expression
Service is not available to resolve those, so we need to assign those
exactly.
Post the SQL statement for tstquery3 (by switching from query design to SQL
View (on the View menu.))