Passing info from unbound option group to table fields

R

rocketD

Hello,

I have an option group with two options. For one option (called
signin), I have the option value set at 1, and for the other (called
visit), the value is -1. I want to pass the value of the signin
option (1) to a numeric field called "numSignIns" if that option is
selected, and the value of the visit option (-1) to a yes/no field
called "visit" if it is selected. Whatever option is NOT selected I'm
assuming will not have any value passed, which is fine. I have the
following SQL set up to add a record at the press of a button, and for
the other fields in the code it works, but the values from the option
buttons are not passed no matter which option is selected.

DoCmd.RunSQL "INSERT INTO tblClinicTrain(PEARID, ClinicID, startDate,
numSignIns, Visit)" & _
"VALUES(forms.fmParticipantRecords.PEARID,
forms.fmParticipantRecords.ClinicID," & _
"forms.fmParticipantRecords.clinicStartDate,
forms.fmParticipantRecords.signin," & _
"forms.fmParticipantRecords.visit);"

Can someone please explain where I'm going wrong, or if there's a
better way to do this?

Thanks,
Dara
 
G

ghetto_banjo

Options Groups only store the selected value. I don't believe you can
reference the individual options like that, only the group/frame
itself.

Option Groups by default will have a name like Frame01, which you can
update if you want.

You can use an if statement to alter your SQL statement accoringly.

i.e.
if Frame01 = -1 then
.....
else
....
end if

Also, I normally reference form fields directly, like:
"VALUES(" & me.PearID & ", " & me.ClinicID & .....


This seems to be the common way of doing it, but I can't say for sure
if it is that advantageous.
 
R

rocketD

Options Groups only store the selected value.  I don't believe you can
reference the individual options like that, only the group/frame
itself.

Option Groups by default will have a name like Frame01, which you can
update if you want.

You can use an if statement to alter your SQL statement accoringly.

i.e.
if Frame01 = -1 then
....
else
...
end if

Also, I normally reference form fields directly, like:
"VALUES(" & me.PearID & ", " & me.ClinicID & .....

This seems to be the common way of doing it, but I can't say for sure
if it is that advantageous.

Thanks for your advice. I ended up doing an If statement that
contained SQL for one option, then the else contained SQL for the
other option. I don't know if that's what you had in mind, but it
works, so I appreciate it.
 

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