type mismatch

G

Guest

I have a "report to file" button that returns a "Type mismatch" error. Can
anyone see the problem in the following code? I've referenced the Help files
but as always am frustrated by the return. None of the examples appear to be
relative to mine.

Thanks in advance!

Private Sub cmdprintofile_Click()
On Error GoTo Err_cmdprinttofile_Click

Dim stDocName As String
Dim strWhere As String
strWhere = "[txtProfileID] = """ & _
Forms![frmFinishedGoods].Form![txtProfileID] & """"
DoCmd.OutputTo Me!cbSelectReport, acReport, stDocName _
, , strWhere

Exit_cmdprinttofile_Click:
Exit Sub

Err_cmdprinttofile_Click:
MsgBox Err.Description
Resume Exit_cmdprinttofile_Click

End Sub
 
M

missinglinq via AccessMonster.com

You’ve got too many double quotes and no single quotes in your strWhere line.

I think

strWhere = "[txtProfileID] = """ & Forms![frmFinishedGoods].Form!
[txtProfileID] & """"

should be

strWhere = "[txtProfileID]='" & Forms![frmFinishedGoods].Form![txtProfileID]
& "'"

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
G

Guest

Thanks. I was reluctant to try that as the same string works for my other
buttons however I gave it a shot and it still returned "Type mismatch".
 
M

missinglinq via AccessMonster.com

Also, in looking closer and checking with Access Help, it looks to me like
your statement

DoCmd.OutputTo Me!cbSelectReport, acReport, stDocName , , strWhere

isn't the correct syntax

From Help:

DoCmd.OutputTo objecttype[, objectname][, outputformat][, outputfile][,
autostart][, templatefile]

It looks like you've omitted the objecttype, which Help doesn't list as being
optional.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
G

Guest

Thanks - I see now!

I've added "acOutputReport" but something's not right. It literally shuts
down Access when I try to execute it therefore, I'm not sure what I've done
wrong.

DoCmd.OutputTo acOutputReport, Me!cbSelectReport, stDocName , , strWhere
 

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

Similar Threads

button to print to Acrobat Distiller 4
Report VB Code 1
data type mismatch 4
Error 13 - Type Mismatch 5
ReportToPDF 15
Not able to print current record... 2
Combo Box & Report Questions 22
command button - add record 1

Top