"dannie" <(E-Mail Removed)> wrote in message
news:C67706AF-ADBB-4F0F-90D3-(E-Mail Removed)...
>I am getting a Compile error: Type-declaration character does not match
> declared data type
>
>
> Private Sub optMH1_Click()
> Call SelectMHform(1)
> End Sub
>
> Sub SelectMHform(a As Integer)
> With Forms("BaseForm")
> .optMH& a&.value = 1
> .txtPicture.value = "MH" + Str(a)
> .cmbBoxMaterial.value = ""
> .txtBoxLength.value = ""
> End With
> End Sub
>
> I tried some other things too but I am still getting an error due to
> .optMH&
> a&.value = 1 How do I use a variable in this situation?
Ampersand (&) is the type declaration character for a Long data type, not an
integer. There really is no need to use type declaration characters in VBA
(except in rare circumstances when calling a routine in a DLL). Dim(ension)
your variables instead.
a&.value will never work, because you're using object syntax, and an object
can't be a Long (it's an Object).
|