From: rocketD on
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
From: ghetto_banjo on
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.

From: rocketD on
On May 12, 12:43 pm, ghetto_banjo <adam.v...(a)gmail.com> wrote:
> 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.
From: ghetto_banjo on
yep thats what i was going for. glad it worked!