Option Groups, and updating

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I've got an option group with 5 options, with no default value. Whenever I
open the form and scroll through records all of the options are grey'd,
unless the user selects one.

The way things are set up right now, I've got an option group with 5
options, representing folders where a file is stored. The database is then
linked to a webpage, and that field is used along with the name of the file
to create a hyperlink to the file. One of the options I have is an "other"
option, that has a textbox next to it that allows the user to input in a
specified folder. That way, in the future, if we add a new folder to store
files in the form would still work.

What I would like to do is have the option group display the current value
of the options, depending on the record being viewed. So that as you scroll
through records whatever option is currently selected (based on the table)
for that record is already selected in the option group.

I've got an if statement setup that *should* handle this, but I'm not sure
where to place the code. I've tried to use form_activate() and
form_AfterUpdate(), but niether seems to work. Can anyone help me with where
I should put code like this?
 
If the Option group frame is bound to the field in your table, it will
display it. Otherwise, it has no way of knowing which option to display.
Open your form in design view. Open the property sheet. Select the frame of
the Option group and set its ControlSource property to the field in your
table.
 
Maybe I am mis-reading your post. I think Option Groups are normally bound
to a field in the record and would therefore display 'whatever option is
currently selected (based on the table) for that record is already selected
in the option group.'

Say again what your Option Group is connected to. Where is it's data
(selection) stored?
 
You could put the code in a function into which the current value of the
field containing the path is passed as an argument. The function would
return the numeric value of the option group. If the path passed in is an
'Other' folder then the function would also (within the body of its code, not
as a return value) assign the value in the field to the text box. Call the
function as the option group's ControlSource property.

However, why not simply use a combo box bound to the field in question? The
field would of course be a foreign key referencing a Folders table in which
each path is represented by one row and the combo box's RowSource would draw
upon that table. When you want to add a new path the NotInList event
procedure of the combo box can be used to add a new row to the Folders table.

Rather than users having to type in the path to a new folder you can open a
common dialogue for this. Take a look at the following link for one way to
do this:


http://www.developerfusion.co.uk/show/2127


Paste the code into a new module and open the dialogue with:

Me.PathToFolder = GetBrowse()

where PathToFolder is the control bound to the field in the form's
underlying table.

Ken Sheridan
Stafford, England
 
Back
Top