Option Group Autofill

R

Robbie Doo

Is it possible to fill the Option Group automatically depending on a field
value on the Main form?
I want my Option to mark the 1st radio button when the days are less than 15
or the 2nd button if the days are between 16-25 and so on...

Thank you,
 
B

Beetle

You can use some code like the following in the Current event of your
form and the After Update event of your "days" control;

Select Case Me![YourDaysControl]
Case < 16
Me![YourOptionGroup] = 1
Case < 26
Me![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![YourOptionGroup] = 3
End Select
 
R

Robbie Doo

Thank you Sean for the input. I forgot to mention that the Option Group is a
Subform feeding from a different Table. This method gave me an error.

Beetle said:
You can use some code like the following in the Current event of your
form and the After Update event of your "days" control;

Select Case Me![YourDaysControl]
Case < 16
Me![YourOptionGroup] = 1
Case < 26
Me![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![YourOptionGroup] = 3
End Select
--
_________

Sean Bailey


Robbie Doo said:
Is it possible to fill the Option Group automatically depending on a field
value on the Main form?
I want my Option to mark the 1st radio button when the days are less than 15
or the 2nd button if the days are between 16-25 and so on...

Thank you,
 
B

Beetle

I forgot to mention that the Option Group is a Subform

Not following you. An Option Group is not the same thing as a Subform. Did
you mean that the Option Group is placed within a subform? If so, you would
modify as follows;

Select Case Me![YourDaysControl]
Case < 16
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 1
Case < 26
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 3
End Select

--
_________

Sean Bailey


Robbie Doo said:
Thank you Sean for the input. I forgot to mention that the Option Group is a
Subform feeding from a different Table. This method gave me an error.

Beetle said:
You can use some code like the following in the Current event of your
form and the After Update event of your "days" control;

Select Case Me![YourDaysControl]
Case < 16
Me![YourOptionGroup] = 1
Case < 26
Me![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![YourOptionGroup] = 3
End Select
--
_________

Sean Bailey


Robbie Doo said:
Is it possible to fill the Option Group automatically depending on a field
value on the Main form?
I want my Option to mark the 1st radio button when the days are less than 15
or the 2nd button if the days are between 16-25 and so on...

Thank you,
 
B

Beetle

No because it exits the statement as soon as a condition is met. By the
time it gets to the second case we already know the value is > 15,
otherwise it would have exited at the first case. Ditto for the third case.

Not that there is anything wrong with doing it as you suggest. Maybe I'm
just lazy and like to type as little as possible. :)
--
_________

Sean Bailey


Damon Heron said:
Wouldn't this Select Case always be Option 3? If the range is 16 to 25,
better to use Case >15 and <26 or what ever the syntax is.

Damon

Beetle said:
I forgot to mention that the Option Group is a Subform

Not following you. An Option Group is not the same thing as a Subform. Did
you mean that the Option Group is placed within a subform? If so, you
would
modify as follows;

Select Case Me![YourDaysControl]
Case < 16
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 1
Case < 26
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 3
End Select

--
_________

Sean Bailey


Robbie Doo said:
Thank you Sean for the input. I forgot to mention that the Option Group
is a
Subform feeding from a different Table. This method gave me an error.

:

You can use some code like the following in the Current event of your
form and the After Update event of your "days" control;

Select Case Me![YourDaysControl]
Case < 16
Me![YourOptionGroup] = 1
Case < 26
Me![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![YourOptionGroup] = 3
End Select
--
_________

Sean Bailey


:

Is it possible to fill the Option Group automatically depending on a
field
value on the Main form?
I want my Option to mark the 1st radio button when the days are less
than 15
or the 2nd button if the days are between 16-25 and so on...

Thank you,
 
R

Robbie Doo

Thank you Sean. Everything worked perfectly.

Beetle said:
No because it exits the statement as soon as a condition is met. By the
time it gets to the second case we already know the value is > 15,
otherwise it would have exited at the first case. Ditto for the third case.

Not that there is anything wrong with doing it as you suggest. Maybe I'm
just lazy and like to type as little as possible. :)
--
_________

Sean Bailey


Damon Heron said:
Wouldn't this Select Case always be Option 3? If the range is 16 to 25,
better to use Case >15 and <26 or what ever the syntax is.

Damon

Beetle said:
I forgot to mention that the Option Group is a Subform

Not following you. An Option Group is not the same thing as a Subform. Did
you mean that the Option Group is placed within a subform? If so, you
would
modify as follows;

Select Case Me![YourDaysControl]
Case < 16
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 1
Case < 26
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![NameOfYourSubformControl].Form![YourOptionGroup] = 3
End Select

--
_________

Sean Bailey


:

Thank you Sean for the input. I forgot to mention that the Option Group
is a
Subform feeding from a different Table. This method gave me an error.

:

You can use some code like the following in the Current event of your
form and the After Update event of your "days" control;

Select Case Me![YourDaysControl]
Case < 16
Me![YourOptionGroup] = 1
Case < 26
Me![YourOptionGroup] = 2
Case < 41 (or whatever)
Me![YourOptionGroup] = 3
End Select
--
_________

Sean Bailey


:

Is it possible to fill the Option Group automatically depending on a
field
value on the Main form?
I want my Option to mark the 1st radio button when the days are less
than 15
or the 2nd button if the days are between 16-25 and so on...

Thank you,
 

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