VB error - User-defined type not defined

T

Tim Cadieux

When doing this Dim frmName As Form

I get this error

User-defined type not defined?

Do I need to add a reference?

Below is the full code so u can see what I'm doing.


Dim frmName As Form

'Determine which Form to Show

If Me.optIndivid.Value = True Then

Set frmName = Forms.Add("frmRecipient")

Else

Set frmName = Forms.Add("frmSalut")

End If


'Get the Label Translations

If sLang = "0" Then

sDear = "Dear"

sNone = "[None]"

Else

sDear = "Cher"

sNone = "[Aucune]"

End If



'Show the translations and show the form

With frmName

.listSalutation.AddItem sDear

.listSalutation.AddItem sNone

.Show

End With
 
J

JGM

Salut Tim,

I am not sure abut your Word Version, but, I think this has been a standard
since Office 97.
Dim frmName As Form
is wrong. I think you want to use
Dim frmName As UserForm

I do not understand how you ended up with
Dim frmName As Form

Did you not notice that Form was not available in the automatic list that
appears as soon as you typed "As"? Maybe you copied the code from a Website
and then changed the parts you needed? Or, how are you writing your code?
Are you in the Word VBA Editor? If so, check your settings in Options from
the Tools menu, go to the Editor Tab, and most checkboxes should be checked,
anyway, I mine are, it makes my life easier. When I type code and I try to
use words that are not in the automatic list, I always get an error. Also, I
always type in lower case (And I always declare my variables with some upper
case letters in them), so that when I hit enter at the end of a code line,
the Editor automatically puts in all the uppercase letters. If some words
stay in lower case, I know something is wrong. This should have happen to
you when you typed your Dim line, unless you typed "Form" with an Uppercase
F.

HTH
À+

--
_______________________________________
Jean-Guy Marcil
(e-mail address removed)

Tim Cadieux said:
When doing this Dim frmName As Form

I get this error

User-defined type not defined?

Do I need to add a reference?

Below is the full code so u can see what I'm doing.


Dim frmName As Form

'Determine which Form to Show

If Me.optIndivid.Value = True Then

Set frmName = Forms.Add("frmRecipient")

Else

Set frmName = Forms.Add("frmSalut")

End If


'Get the Label Translations

If sLang = "0" Then

sDear = "Dear"

sNone = "[None]"

Else

sDear = "Cher"

sNone = "[Aucune]"

End If



'Show the translations and show the form

With frmName

.listSalutation.AddItem sDear

.listSalutation.AddItem sNone

.Show

End With
 

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