PC Review


Reply
Thread Tools Rate Thread

DoCmd.OutputTo wrong data type

 
 
Guest
Posts: n/a
 
      20th Jul 2009
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


 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      20th Jul 2009
Have you defined the data type of the parameters in the queries?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"< AVG Joe" <(E-Mail Removed)> wrote in message
news3DD3D3B-8A01-47A7-B56C-(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Guest
Posts: n/a
 
      20th Jul 2009
No. It's just a prompt from the QBE pane:
"Between [Start] AND [End]"

(those are dates)

I think I got the type issue-by using qdfQry.Name in the DoCmd, but still
can't
get the input boxes to override/replace the input parameters...

"Douglas J. Steele" wrote:

> Have you defined the data type of the parameters in the queries?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "< AVG Joe" <(E-Mail Removed)> wrote in message
> news3DD3D3B-8A01-47A7-B56C-(E-Mail Removed)...
> > 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
> >
> >

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      20th Jul 2009
Try defining the parameter types:

PARAMETERS Start DateTime, End DateTime;

before what's currently there in the SQL view.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"< AVG Joe" <(E-Mail Removed)> wrote in message
news:FCE077F7-2DE5-44A4-B4F6-(E-Mail Removed)...
> No. It's just a prompt from the QBE pane:
> "Between [Start] AND [End]"
>
> (those are dates)
>
> I think I got the type issue-by using qdfQry.Name in the DoCmd, but still
> can't
> get the input boxes to override/replace the input parameters...
>
> "Douglas J. Steele" wrote:
>
>> Have you defined the data type of the parameters in the queries?
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "< AVG Joe" <(E-Mail Removed)> wrote in message
>> news3DD3D3B-8A01-47A7-B56C-(E-Mail Removed)...
>> > 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
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
Guest
Posts: n/a
 
      21st Jul 2009
No dice. I am still prompted for each input box and parameter.

"Douglas J. Steele" wrote:

> Try defining the parameter types:
>
> PARAMETERS Start DateTime, End DateTime;
>
> before what's currently there in the SQL view.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "< AVG Joe" <(E-Mail Removed)> wrote in message
> news:FCE077F7-2DE5-44A4-B4F6-(E-Mail Removed)...
> > No. It's just a prompt from the QBE pane:
> > "Between [Start] AND [End]"
> >
> > (those are dates)
> >
> > I think I got the type issue-by using qdfQry.Name in the DoCmd, but still
> > can't
> > get the input boxes to override/replace the input parameters...
> >
> > "Douglas J. Steele" wrote:
> >
> >> Have you defined the data type of the parameters in the queries?
> >>
> >> --
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no e-mails, please!)
> >>
> >>
> >> "< AVG Joe" <(E-Mail Removed)> wrote in message
> >> news3DD3D3B-8A01-47A7-B56C-(E-Mail Removed)...
> >> > 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
> >> >
> >> >
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      21st Jul 2009
Another option, then, would be to have a form with text boxes (or calendar
controls, or combo boxes) on it, and have the queries refer to those
controls rather than using named parameters.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"< AVG Joe" <(E-Mail Removed)> wrote in message
newsD9627FA-41F1-48C0-A2B8-(E-Mail Removed)...
> No dice. I am still prompted for each input box and parameter.
>
> "Douglas J. Steele" wrote:
>
>> Try defining the parameter types:
>>
>> PARAMETERS Start DateTime, End DateTime;
>>
>> before what's currently there in the SQL view.
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no e-mails, please!)
>>
>>
>> "< AVG Joe" <(E-Mail Removed)> wrote in message
>> news:FCE077F7-2DE5-44A4-B4F6-(E-Mail Removed)...
>> > No. It's just a prompt from the QBE pane:
>> > "Between [Start] AND [End]"
>> >
>> > (those are dates)
>> >
>> > I think I got the type issue-by using qdfQry.Name in the DoCmd, but
>> > still
>> > can't
>> > get the input boxes to override/replace the input parameters...
>> >
>> > "Douglas J. Steele" wrote:
>> >
>> >> Have you defined the data type of the parameters in the queries?
>> >>
>> >> --
>> >> Doug Steele, Microsoft Access MVP
>> >> http://I.Am/DougSteele
>> >> (no e-mails, please!)
>> >>
>> >>
>> >> "< AVG Joe" <(E-Mail Removed)> wrote in message
>> >> news3DD3D3B-8A01-47A7-B56C-(E-Mail Removed)...
>> >> > 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
>> >> >
>> >> >
>> >>
>> >>
>> >>

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DoCmd.OutputTo Jeff Microsoft Access External Data 0 6th May 2008 04:46 AM
DoCmd.OutputTo Opal Microsoft Access VBA Modules 8 3rd May 2008 02:18 AM
DoCmd.OutputTo acOutputQuery missing data janiotjoeawie via AccessMonster.com Microsoft Access External Data 0 16th Feb 2007 12:40 PM
DoCmd.OutputTo TAMMY Microsoft Access External Data 1 8th Jul 2004 09:03 PM
Export Binary Data type using DoCmd.OutputTo Don Microsoft Access VBA Modules 0 7th Jun 2004 05:51 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:52 PM.