Userform from VBA

G

Guest

This code sort of works in my userform
Sub checkboxDG_Change(
With Me.checkboxD
If Me.checkboxDG.value = True The
strDG = "DG
Me.FrameDG.obReqDG.Enabled = Tru
Me.FrameDG.obOptDG.Enabled = Tru
Els
Me.checkboxDG = Fals
Me.FrameDG.obReqDG.value = Fals
Me.FrameDG.obOptDG.value = Fals
Me.FrameDG.obReqDG.Enabled = Fals
Me.FrameDG.obOptDG.Enabled = Fals
End I
End Wit
If obReqDG = True Then strDGtype = olRequire
If obOptDG = True Then strDGtype = olOptiona
End Su

The problem is that if the checkbox is turned on then off any of the information is loas tnad never gets moved to another routine thus I end up with no data in the strings. Why is this happening. It seems that it only happens when the checkbox gets turned on then off. The data is supposed to be carried over to this part

SUB........
If strDG = "" The
GoTo line
Els
Set myRequiredAttendee = myitem.Recipients.Add(strDG
myRequiredAttendee.Type = strDGtyp
End I
..........
END SU
but this does not always work. I have made the strDG and strDGtype Public as strings. I am really stummped. The original goal was to disable the option buttons if the checkbox is false and if the checkbox is true then the option buttons can be selected.

TI
 
S

Sue Mosher [MVP-Outlook]

But *where* did you declare strDG and strDGtype Public? Those declarations
need to be in a regular module, not a form or class module.

Shouldn't you be using Me.FrameDG.obReqDG.value when you set the variable
values?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Greg said:
This code sort of works in my userform.
Sub checkboxDG_Change()
With Me.checkboxDG
If Me.checkboxDG.value = True Then
strDG = "DG"
Me.FrameDG.obReqDG.Enabled = True
Me.FrameDG.obOptDG.Enabled = True
Else
Me.checkboxDG = False
Me.FrameDG.obReqDG.value = False
Me.FrameDG.obOptDG.value = False
Me.FrameDG.obReqDG.Enabled = False
Me.FrameDG.obOptDG.Enabled = False
End If
End With
If obReqDG = True Then strDGtype = olRequired
If obOptDG = True Then strDGtype = olOptional
End Sub

The problem is that if the checkbox is turned on then off any of the
information is loas tnad never gets moved to another routine thus I end up
with no data in the strings. Why is this happening. It seems that it only
happens when the checkbox gets turned on then off. The data is supposed to
be carried over to this part.
SUB.........
If strDG = "" Then
GoTo line1
Else
Set myRequiredAttendee = myitem.Recipients.Add(strDG)
myRequiredAttendee.Type = strDGtype
End If
..........
END SUB
but this does not always work. I have made the strDG and strDGtype Public
as strings. I am really stummped. The original goal was to disable the
option buttons if the checkbox is false and if the checkbox is true then the
option buttons can be selected.
 
S

Sue Mosher [MVP-Outlook]

Move the Public statement from the form module to the module that calls the
userform.

yes, try it with those statements, which match the syntax you're using
earlier in your proceudre.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Greg said:
Sue,
I declared them (the public statment)in the code that is in the
userform not in the module that calls the userform. And are you saying that
this should be changed from
If obReqDG = True Then strDGtype = olRequired
If obOptDG = True Then strDGtype = olOptional

to

If Me.FrameDG.obReqDG.value = True Then strDGtype = olRequired
If Me.FrameDG.obReqDG.value = True Then strDGtype = olOptional

Thanks
Sue
----- Sue Mosher [MVP-Outlook] wrote: -----

But *where* did you declare strDG and strDGtype Public? Those declarations
need to be in a regular module, not a form or class module.

Shouldn't you be using Me.FrameDG.obReqDG.value when you set the variable
values?

Greg said:
This code sort of works in my userform.
Sub checkboxDG_Change()
With Me.checkboxDG
If Me.checkboxDG.value = True Then
strDG = "DG"
Me.FrameDG.obReqDG.Enabled = True
Me.FrameDG.obOptDG.Enabled = True
Else
Me.checkboxDG = False
Me.FrameDG.obReqDG.value = False
Me.FrameDG.obOptDG.value = False
Me.FrameDG.obReqDG.Enabled = False
Me.FrameDG.obOptDG.Enabled = False
End If
End With
If obReqDG = True Then strDGtype = olRequired
If obOptDG = True Then strDGtype = olOptional
End Sub
the
information is loas tnad never gets moved to another routine thus I end up
with no data in the strings. Why is this happening. It seems that it only
happens when the checkbox gets turned on then off. The data is supposed to
be carried over to this part.
If strDG = "" Then
GoTo line1
Else
Set myRequiredAttendee = myitem.Recipients.Add(strDG)
myRequiredAttendee.Type = strDGtype
End If
..........
END SUB
but this does not always work. I have made the strDG and strDGtype
Public
as strings. I am really stummped. The original goal was to disable the
option buttons if the checkbox is false and if the checkbox is true then the
option buttons can be selected.
 
S

Sue Mosher [MVP-Outlook]

Your code for checkbox = False sets the values for the obReqDG and obOptDG
controls, but the corresponding code for checkbox = True does not set the
values for those controls. Hence, the value is always False for those
controls is always False at the point where you set the value of , because
the user never has a chance to select the obReqDG or obOptDG control. I
think you need to add logic to set strDGtype when the user selects one of
those controls.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Greg said:
Sue,
That still doesn't fix the problem any other thoughts. The value that
I am loosing is the is the stringDGtype but this only happens if the
checkbox gets turned on then off then on. So the value of the strDGtype does
get sets once but then it seems as if it never can get it againif the box
gets turned off. I hope that this makes sense.
 

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