Making a data string object for VBA

R

red6000

Hi,
I have an item of data that I want to evaluate whether it is true or false
and then process, but I'm having a problem... at the moment I have:

Private Sub CommandButton2_Click()

Dim UFno As Integer

Dim Item1 As String

Dim OBno As Integer

UFno = 21

OBno = 1

Item1 = "UserForm" & UFno & "." & "OptionButton" & OBno

If Item1 = True Then

Selection.TypeText Text:=Item1

End If

End Sub

When I run the code I get an item mismatch and it highlights the line 'If
Item1 = True Then'.

Can anyone help?

Thanks.
 
H

Helmut Weber

Hi,
hm...
never heard of a data string object.

I think you want to know, whether item1 is empty.

if item1 = "" then


Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000
 
J

Jonathan West

Hi red,

Try this

Dim UF As Object
Dim Item1 As Control
Dim UFno As Integer
Dim OBno As Integer

UFno = 21
OBno = 1

For Each UF In UserForms
If UF.name = "UserForm" & UFno Then
Set Item1 = UF.Controls("OptionButton" & OBno)
If Item1.Value Then
Selection.TypeText Text:=Item1.name
End If
End If
Next UF


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

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