C
charles.kendricks
I have a report which simply displays a subset of church visitors whose
first visit is between a user specified pair of dates. The code which
I tied to the OnOpen event of the report is as follows:
Private Sub Report_Open(Cancel As Integer)
Dim dteBegin As Variant
Dim dteEnd As Variant
Dim strSql As String
dteBegin = InputBox("Please Enter Beginning Date", "Enter Dates")
dteEnd = InputBox("Please Enter Ending Date", "Enter Dates")
strSql = "SELECT tblVisitors.ID, tblVisitors.Salutation,
tblVisitors.FirstName,"
strSql = strSql + " tblVisitors.LastName, tblVisitors.Address,
tblVisitors.City,"
strSql = strSql + " tblVisitors.State, tblVisitors.Zip,
tblVisitors.HomePhone,"
strSql = strSql + " tblVisitors.FirstTime, tblVisitors.FollowUp,
tblVisitors.Who,"
strSql = strSql + " tblVisitors.Comments, tblVisitors.RegMem,
tblVisitors.HomeChurch,"
strSql = strSql + " tblVisitors.Reason, tblVisitors.FirstVisit,
[Address]+' '+[City]+"
strSql = strSql + "', '+[State]+'. '+[zip] AS WholeAddr FROM
tblVisitors"
strSql = strSql + " WHERE (((tblVisitors.LastName) Is Not Null)
AND"
strSql = strSql + " ((tblVisitors.FirstVisit) Between " + dteBegin
+ " And " + dteEnd + "))"
DoCmd.RunSQL strSql
End Sub
When I set the dteBegin and dteEnd variable as Variant data type I get
the error message:
Run-time error '2342':
"A RunSQLO action requires an argument consisting of an SQL statement".
When I set same two variables as Date date type I get a:
Run-time error '13'
Data type mismatch
in the latter example the interface highlights the last strSql string
assignment.
What am I doing wrong???
Charles
first visit is between a user specified pair of dates. The code which
I tied to the OnOpen event of the report is as follows:
Private Sub Report_Open(Cancel As Integer)
Dim dteBegin As Variant
Dim dteEnd As Variant
Dim strSql As String
dteBegin = InputBox("Please Enter Beginning Date", "Enter Dates")
dteEnd = InputBox("Please Enter Ending Date", "Enter Dates")
strSql = "SELECT tblVisitors.ID, tblVisitors.Salutation,
tblVisitors.FirstName,"
strSql = strSql + " tblVisitors.LastName, tblVisitors.Address,
tblVisitors.City,"
strSql = strSql + " tblVisitors.State, tblVisitors.Zip,
tblVisitors.HomePhone,"
strSql = strSql + " tblVisitors.FirstTime, tblVisitors.FollowUp,
tblVisitors.Who,"
strSql = strSql + " tblVisitors.Comments, tblVisitors.RegMem,
tblVisitors.HomeChurch,"
strSql = strSql + " tblVisitors.Reason, tblVisitors.FirstVisit,
[Address]+' '+[City]+"
strSql = strSql + "', '+[State]+'. '+[zip] AS WholeAddr FROM
tblVisitors"
strSql = strSql + " WHERE (((tblVisitors.LastName) Is Not Null)
AND"
strSql = strSql + " ((tblVisitors.FirstVisit) Between " + dteBegin
+ " And " + dteEnd + "))"
DoCmd.RunSQL strSql
End Sub
When I set the dteBegin and dteEnd variable as Variant data type I get
the error message:
Run-time error '2342':
"A RunSQLO action requires an argument consisting of an SQL statement".
When I set same two variables as Date date type I get a:
Run-time error '13'
Data type mismatch
in the latter example the interface highlights the last strSql string
assignment.
What am I doing wrong???
Charles