If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Passing info from unbound option group to table fields
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 |
#2
|
|||
|
|||
Passing info from unbound option group to table fields
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. |
#3
|
|||
|
|||
Passing info from unbound option group to table fields
On May 12, 12:43*pm, ghetto_banjo 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. |
#4
|
|||
|
|||
Passing info from unbound option group to table fields
yep thats what i was going for. glad it worked!
|
Thread Tools | |
Display Modes | |
|
|