G
Guest
Access 2003.
Trying to an export of query using DoCmd.OutputTo.
The problem is passing the query paramters (I think)
The 1st query-takes in two prompt type parameters.
The 2nd query - pulls in the first query.
Thus if the user needs to enter a start & end date they are prompted a total
of 4 times.
I am trying to override that with input boxes and then setting the parms
equal to that.
However-when I put ht querydef variable in the"DoCmd" I receive an error
(Run-time 2498. "An expression you entered is the wrong data type for one of
the arguments) for an invalid data type-which I think is the query name.
Putting the query names in as literals works fine, but then we are prompted 4
times. Code below. Any help would appreciated.
Function ReconInvs()
Dim db As DAO.Database
Dim qdfQry As QueryDef
Dim qdfQry2 As QueryDef
Dim strStart As String
Dim strEnd As String
Set db = CurrentDb()
Set qdfQry = db.QueryDefs("ReconInvSvcDates")
Set qdfQry2 = db.QueryDefs("ReconInvSummary")
strStart = InputBox("Please enter Start date (mm/dd/yyyy)")
strEnd = InputBox("Please enter Start date (mm/dd/yyyy)")
qdfQry.Parameters(0) = strStart
qdfQry.Parameters(1) = strEnd
qdfQry2.Parameters(0) = strStart
qdfQry2.Parameters(1) = strEnd
DoCmd.OutputTo acOutputQuery, qdfQry, acFormatXLS, _
"C:\Documents and Settings\" & Environ("USERNAME") &
"\Desktop\ReconInvSvcDates" & Format(strEnd, "yyyymmdd") & ".xls", True, "",
0 _
DoCmd.OutputTo acOutputQuery, qdfQry2, acFormatXLS, _
"C:\Documents and Settings\" & Environ("USERNAME") &
"\Desktop\ReconInvSummary" & Format(strEnd, "yyyymmdd") & ".xls", True, "", 0
_
End Function
Trying to an export of query using DoCmd.OutputTo.
The problem is passing the query paramters (I think)
The 1st query-takes in two prompt type parameters.
The 2nd query - pulls in the first query.
Thus if the user needs to enter a start & end date they are prompted a total
of 4 times.
I am trying to override that with input boxes and then setting the parms
equal to that.
However-when I put ht querydef variable in the"DoCmd" I receive an error
(Run-time 2498. "An expression you entered is the wrong data type for one of
the arguments) for an invalid data type-which I think is the query name.
Putting the query names in as literals works fine, but then we are prompted 4
times. Code below. Any help would appreciated.
Function ReconInvs()
Dim db As DAO.Database
Dim qdfQry As QueryDef
Dim qdfQry2 As QueryDef
Dim strStart As String
Dim strEnd As String
Set db = CurrentDb()
Set qdfQry = db.QueryDefs("ReconInvSvcDates")
Set qdfQry2 = db.QueryDefs("ReconInvSummary")
strStart = InputBox("Please enter Start date (mm/dd/yyyy)")
strEnd = InputBox("Please enter Start date (mm/dd/yyyy)")
qdfQry.Parameters(0) = strStart
qdfQry.Parameters(1) = strEnd
qdfQry2.Parameters(0) = strStart
qdfQry2.Parameters(1) = strEnd
DoCmd.OutputTo acOutputQuery, qdfQry, acFormatXLS, _
"C:\Documents and Settings\" & Environ("USERNAME") &
"\Desktop\ReconInvSvcDates" & Format(strEnd, "yyyymmdd") & ".xls", True, "",
0 _
DoCmd.OutputTo acOutputQuery, qdfQry2, acFormatXLS, _
"C:\Documents and Settings\" & Environ("USERNAME") &
"\Desktop\ReconInvSummary" & Format(strEnd, "yyyymmdd") & ".xls", True, "", 0
_
End Function