type mismatch

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