type mismatch error

S

Steve S

Can anyone tell my why the following Dim/Set code produces a 'type mismatch'
error?

Dim frmName As Form
Set frmName = Forms![Reports Dialog].Combo62

I know the form/control name is correct because the next 2 lines display the
value that is showing in the control

strPrintScoreSheet = [Forms]![Reports Dialog].Combo62.Column(1)
MsgBox strPrintScoreSheet

HELP
 
D

Douglas J. Steele

You've declared frmName to be a form, yet you're setting it equal to the
value found in Combo62.

If what you're trying to do is retrieve a form name from the combo box, try

Set frmName = Forms(Forms![Reports Dialog].Combo62)

Of course, that will only work if the form's already open. If it isn't,
you'll need to open it first:

DoCmd.OpenForm Forms![Reports Dialog].Combo62

or you can always open it hidden using

DoCmd.OpenForm Forms![Reports Dialog].Combo62, windowmode:=acHidden
 
J

John W. Vinson

Can anyone tell my why the following Dim/Set code produces a 'type mismatch'
error?

Dim frmName As Form
Set frmName = Forms![Reports Dialog].Combo62

I know the form/control name is correct because the next 2 lines display the
value that is showing in the control

strPrintScoreSheet = [Forms]![Reports Dialog].Combo62.Column(1)
MsgBox strPrintScoreSheet

HELP

Probably because the second column (Column(1) is the second column, it's zero
based) is not the bound column of the combo. It's confusing - the Column()
property is zero based, but the BoundColumn property is 1 based.


John W. Vinson [MVP]
 

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

Top