By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,489 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

option button required code needed

P: n/a
In my form I have an option group with 3 option buttons. My form is
tied to a table. the options are Temp, Permanent and Overtime.
I have these inside a frame. I have an AddRecord button to enter the
data into the table. After the record is Added the option buttons are
emptied.

I want to require the person to click one of the option buttons, which
enters the type of employee it is.

In the click event of the AddRecord button I have the following code.

If Me.Frame60.Value = Me.Frame60.DefaultValue Then
MsgBox ("You must pick one of the options")
GoTo Err_cmdUpdate_Click
End If

The Err_cmdUpdate_Click should exit the AddRecord without updating the
table.

The problem is the first time this works, but if they correct the
first one, and they don't enter the type of worker the second time,
the messagebox appears, but the data is entered into the table anyway.

I need a way to make sure the data is only entered if one of the
option buttons is clicked.

When they first open the form, the option buttons are grey, after the
first entry of data, the option boxes are white. I get the feeling
that the option buttons are in a different state at that point, which
is probably causing the frame value to have changed.

Mar 17 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
As I always announce, I'm not an expert but this is what I would do.

As you want to store the results of the option button in your table, I would
add a field, named to your choice of number type and set the 'Required'
property to True. This will make sure that a record created has to have a
value entered for this field.

Make sure the wizard is switched on
From the 'Toolbox' toolbar, drag an option group to your form
Enter your 3 label names (Temp, Perm & Overtime) and hit next
Select "No - I don't want a default" and hit next
The values should be displayed which will be 1, 2 & 3. Hit next
Select "Store the value in this field" and select the new field you've
created
Choose the formatting of your choice and hit next
Give the option group a meaningful name and hit finish

Regards,

Mark
"Stephen D Cook" <st******@comcast.net> wrote in message
news:60********************************@4ax.com...
In my form I have an option group with 3 option buttons. My form is
tied to a table. the options are Temp, Permanent and Overtime.
I have these inside a frame. I have an AddRecord button to enter the
data into the table. After the record is Added the option buttons are
emptied.

I want to require the person to click one of the option buttons, which
enters the type of employee it is.

In the click event of the AddRecord button I have the following code.

If Me.Frame60.Value = Me.Frame60.DefaultValue Then
MsgBox ("You must pick one of the options")
GoTo Err_cmdUpdate_Click
End If

The Err_cmdUpdate_Click should exit the AddRecord without updating the
table.

The problem is the first time this works, but if they correct the
first one, and they don't enter the type of worker the second time,
the messagebox appears, but the data is entered into the table anyway.

I need a way to make sure the data is only entered if one of the
option buttons is clicked.

When they first open the form, the option buttons are grey, after the
first entry of data, the option boxes are white. I get the feeling
that the option buttons are in a different state at that point, which
is probably causing the frame value to have changed.

Mar 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.