A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Passing info from unbound option group to table fields



 
 
Thread Tools Display Modes
  #1  
Old May 12th, 2010, 07:41 PM posted to microsoft.public.access
rocketD
external usenet poster
 
Posts: 60
Default 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  
Old May 12th, 2010, 08:43 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default 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  
Old May 13th, 2010, 12:20 AM posted to microsoft.public.access
rocketD
external usenet poster
 
Posts: 60
Default 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  
Old May 13th, 2010, 01:38 PM posted to microsoft.public.access
ghetto_banjo
external usenet poster
 
Posts: 325
Default Passing info from unbound option group to table fields

yep thats what i was going for. glad it worked!
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:41 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.