I'm trying to set an (within options table, tblOptions) a setting that can
be read, whehter all reports should be printed or previewed. I'm happy to
email a sample db if required. When I use the setting I get a Run-time error
'13' Type mismatch!!
I have:
1 table - tblOptions with
1 field - "PrintOrPreview" - a 50 character Text field
1 report - "rptTEST" - just a label on it
1 form - with a button and a combo box to chaing the vaule of
"PrintOrPreview"
The code for the combo box:
Private Sub cmbPrintOrPreview_AfterUpdate()
Call SetPrintChoice
End Sub
Which is:
Function SetPrintChoice()
Dim rst As DAO.Recordset
Dim stSQL As String
stSQL = "SELECT * FROM tblOptions;"
Set rst = CurrentDb.OpenRecordset(stSQL)
If rst.RecordCount > 0 Then 'in case the options record
has gone!
rst.MoveFirst 'in case another
record was added by mistake!
Select Case rst("PrintOrPreview")
Case "ChooseToPreview"
gblPrintOrPreview = "acViewPreview"
Case "ChooseToPrint"
gblPrintOrPreview = "acViewNormal"
Case Else
gblPrintOrPreview = "acViewPreview"
End Select
'let's see what it's showing....
Debug.Print "Print setting: " & gblPrintOrPreview
End If
End Function
And finally the code for the button:
Private Sub cmdPrint_Click()
' DoCmd.OpenReport "rptTEST", acViewNormal
' DoCmd.OpenReport "rptTEST", acViewPreview
'Either of these work, but as soon as I change it to
DoCmd.OpenReport "rptTEST", gblPrintOrPreview
'then I get a "Type mismatch Error"
End Sub
===========================
Surely this has been done before! What am I do wrong? Please help if you
can, thank you
Jon