SQL string syntax for a control button

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
Back
Top