What I am trying to do is have a set of option buttons which are
required to click one. If the person doesn't click any before insert,
they get an error. If they do click one, it inserts into the field in
the table and then clears the form for the next entry.
I have a form tied to a table. In the table is a lookup field.
In the form I have a frame with 5 option buttons in it.
Outside the frame I have a text box.
I bound the text box to the lookup field.
The form also has an Insert button.
The code I am using is:
cmdInsert_Click()
If Me.opt1.optionvalue = True Then
Me.txtOption.Text = "RF"
End If
If Me.opt2.optionvalue = True Then
Me.txtOption.Text = "25"
End If
..
..
..
..
DoCmd.GoToRecord , , acLast
On Error GoTo Err_cmdUpdate_Click
If Me.Dirty Then
Me.Dirty = False
End If
If Not Me.NewRecord Then
RunCommand acCmdRecordsGoToNew
End If
Me.opt2000.OptionValue = False
Me.opt2500.OptionValue = False
Me.opt700.OptionValue = False
Me.optHD.OptionValue = False
The way I understand it, if the option button is set to True then my
textbox should receive the value from the If statement. If not true,
then the box stays empty. Also, after I Insert the data, the option
buttons will be Off. I have tried this code with opt1.Value set to
True and False as well. I either get a Null value error from the table
because the lookup field is required, or I get a 'This expression has
No Value' error.
What am I doing wrong? Also can you include a snippet to get
me headed in the right direction.