Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Option Group again ! recognize the value of option group

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Dim duration As OptionGroup
Dim duratDat As Integer

duration = Me.duration
duratDat = Me.DataDuration

If duration = 1 Then
Forms![frmStore].[Days] = duratDat

Else
If duration = 2 Then
Forms![frmStore].[Weeks] = duratDat

Else
If duration = 3 Then
Forms![frmStore].[Months] = duratDat
End if

** it told me that "Object variable or with block variable not set" what's that??? i tried to use Select Case also, but the same problems occur. is it correct to recognize the "option 1" as if duration = 1? thanks
 
You don't need to create a variable for the option group on the form or any other value you want from a control on your form. By doing so you're trying to assign a value to an object that can't accept values like that. You don't need to assign values to variables, just use the values directly:

Select Case Me.duration

Case 1
Forms![frmStore].[Days] = Me.DataDuration
Case 2
Forms![frmStore].[Weeks] = Me.DataDuration
Case 3
Forms![frmStore].[Months] = Me.DataDuration

End Select

 
Jerry's answer is correct, but since you asked I'll tell you what the "Object variable or with block variable not set" message is about, in case you run into it in the future (and you probably will).

You declared duration as an OptionGroup. An OptionGroup is a control, and all controls are objects, so "duration" was an "object variable".

Object variables can't be given values with an ordinary "a = b" type statement. You have to use "[red]Set[/red] a = b" for object variables. That's what the message means, in effect. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top