Option Button General Use

cms370

Registered User.
Local time
Today, 07:25
Joined
Jun 9, 2010
Messages
32
I am trying to use the Option Button on a form. I have never used this before and I am experiencing some trouble.

I have two options, one is to be used to "export only new records" and the other is to "re-export".

The default setting for the when the form is first opened should have "export only new records" selected.

Code that I am trying to use:

Private Sub Form_Load()

'When form loads, select the new records option button as default
Me.New_Records_Option.Value = True

End Sub

However, this results in a run time error stating the value can not be assigned. Any ideas?

After this, I would like to use the option button as a trigger, to either export only new records or to re-export.

Code:

If New_Records_Option.Value = True Then

'Export Only New Records

Else

'Export all records

EndIf

Any help is appreciated
 
Did you use the "option group" to build this? If so, it would have assigned 1 for the first value and 2 for the second. (thou you can insert other values) Not "True"...... Couple of easy ways to use the value... either a "if....then" statement or a "Select case"...
I use this code below to make a textbox visible or not depending on the choice in an option group ... This is a "Yes" "No" option group and I have use "-1" and "0" for the values and a select case... Maybe this will give you what you need.

Code:
Private Sub optInterviewed_AfterUpdate()
Select Case Me.optInterviewed
Case Is = -1
Me.InterviewDate.Visible = True
Case Is = 0
Me.InterviewDate.Visible = False
Me.InterviewDate.Value = Null

End Select
End Sub
I would also use the is the forms "Current" event, not on load...
Code:
Private Sub Form_Current()

Select Case Me.optInterviewed
Case Is = -1
Me.InterviewDate.Visible = True
Case Is = 0
Me.InterviewDate.Visible = False

End Select
end sub
Actually for the default value, you don't need the code. Go into the properties of the option group and set it there. Mine is set on the "Current" so it changes as you move through records. I chose not to have a default value in this instance simply to force the user to make a choice... but thats on MY app... You may want a default.. Hope that helps.
 
Last edited:
CEH...thanks for the info. This helped to clear things up for me. Things are working well now.

Also, I used the option group wizard to set the default settings.
 

Users who are viewing this thread

Back
Top Bottom