SQL string syntax for a control button

G

Guest

In my DB I have a form with two fields and a control button:
Field 1: "FirstDate" (Date)
Field 2: "LastDate" (Date)
Button: "OKButton"

The OnClick event for the button should be a procedure which should copy
data from Table1 to Table2:

Private Sub OKButton_Click()
Dim strSQL As String

strSQL = "INSERT INTO Table2 ( TransactionDate, TransactionAmount) " & _
"SELECT TransactionDate, TransactionAmount " & _
"FROM Table1 WHERE ((Table1.TransactionDate) = Between
Me.FirstDate And Me.LastDate)"

CurrentDb.Execute strSQL, dbFailOnError
End Sub

There is something wrong in the syntax of the search condition "Between...
And..."
Please, advise the correct syntax for the above.
Thank you in advance!
Mike
 
S

Squirrel

Hi Mike,

Try this:
strSQL = "INSERT INTO Table2 ( TransactionDate, TransactionAmount) " & _
"SELECT TransactionDate, TransactionAmount " & _
"FROM Table1 WHERE ((Table1.TransactionDate) = Between " & _
"#" & Me.FirstDate & "# And #" & Me.LastDate & "#)"

-Linda
 

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

Top