Making a field in/visible based on a value of another field

I

inventif

Hi,

I have an option group with 5 selections. The last one is "Other" and it
pumps a value of 99 into the underlying field (called Q1).

I would like to display (make visible) another field (called Q1other) when
"Other" (99) is selected from the option group.

I've tried a few combinations of events, even looked at conditional
formatting and nothing seemed to work.

Which event should I use to trigger this behaviour? Also, what code would
you suggest for controlling this situation?

Thank you!
 
C

Chegu Tom

In the afterupdate event of your option group

if q1=99 then or the if statement can reference the
option group if me.optgroup=5 (or something like that)
me.Q1Other.visible=true
else
me.q1Other.visible=false
endif
 
J

Jeff Boyce

In your option group's AfterUpdate event, you could add something like
(untested):

If Me!YourOptionGroupName = 99 Then
Me![Q1 other].Visible = True
Else
Me![Q1 other].Visible = False
End If

You'd also need to make sure that when an existing record was loaded into
the form (check the OnCurrent event), that same code fired again. You could
use something like (also untested):

Call YourOptionGroupName_AfterUpdate()

By the way, and I may be reading too much into the field names you used, if
this is related to a questionnaire/survey (I saw Q1 and thought "question
1"), you may want to post a description of your underlying table structure
to the tablesdbdesign newsgroup to see if there are alternate approaches ...
surveys can be tricky.

By the way, #2 -- use YOUR field names, not the generic ones I wrote above.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
I

inventif

Thank you for the response. I tried what you're suggesting before submitting
my enquiry, but it didn't do the trick. I guess I have to pick some
form-related event that then triggers the IF...THEN...ELSE.
 
I

inventif

Thank you, Jeff, you were spot on. Worked like a charm from the first attempt.

And, yes, I am building a very simple query (one page, 20-ish questions),
being used to "copy" a paper survey into a digital format for easier data
analysis.

Cheers!

Jeff Boyce said:
In your option group's AfterUpdate event, you could add something like
(untested):

If Me!YourOptionGroupName = 99 Then
Me![Q1 other].Visible = True
Else
Me![Q1 other].Visible = False
End If

You'd also need to make sure that when an existing record was loaded into
the form (check the OnCurrent event), that same code fired again. You could
use something like (also untested):

Call YourOptionGroupName_AfterUpdate()

By the way, and I may be reading too much into the field names you used, if
this is related to a questionnaire/survey (I saw Q1 and thought "question
1"), you may want to post a description of your underlying table structure
to the tablesdbdesign newsgroup to see if there are alternate approaches ...
surveys can be tricky.

By the way, #2 -- use YOUR field names, not the generic ones I wrote above.

Regards

Jeff Boyce
Microsoft Office/Access MVP


inventif said:
Hi,

I have an option group with 5 selections. The last one is "Other" and it
pumps a value of 99 into the underlying field (called Q1).

I would like to display (make visible) another field (called Q1other) when
"Other" (99) is selected from the option group.

I've tried a few combinations of events, even looked at conditional
formatting and nothing seemed to work.

Which event should I use to trigger this behaviour? Also, what code would
you suggest for controlling this situation?

Thank you!
 
J

Jeff Boyce

I urge you to investigate Duane H's AtYourSurvey ... it provides an
excellent approach to building Access-based questionnaires/surveys:

http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane

Regards

Jeff Boyce
Microsoft Office/Access MVP

inventif said:
Thank you, Jeff, you were spot on. Worked like a charm from the first
attempt.

And, yes, I am building a very simple query (one page, 20-ish questions),
being used to "copy" a paper survey into a digital format for easier data
analysis.

Cheers!

Jeff Boyce said:
In your option group's AfterUpdate event, you could add something like
(untested):

If Me!YourOptionGroupName = 99 Then
Me![Q1 other].Visible = True
Else
Me![Q1 other].Visible = False
End If

You'd also need to make sure that when an existing record was loaded into
the form (check the OnCurrent event), that same code fired again. You
could
use something like (also untested):

Call YourOptionGroupName_AfterUpdate()

By the way, and I may be reading too much into the field names you used,
if
this is related to a questionnaire/survey (I saw Q1 and thought "question
1"), you may want to post a description of your underlying table
structure
to the tablesdbdesign newsgroup to see if there are alternate approaches
...
surveys can be tricky.

By the way, #2 -- use YOUR field names, not the generic ones I wrote
above.

Regards

Jeff Boyce
Microsoft Office/Access MVP


inventif said:
Hi,

I have an option group with 5 selections. The last one is "Other" and
it
pumps a value of 99 into the underlying field (called Q1).

I would like to display (make visible) another field (called Q1other)
when
"Other" (99) is selected from the option group.

I've tried a few combinations of events, even looked at conditional
formatting and nothing seemed to work.

Which event should I use to trigger this behaviour? Also, what code
would
you suggest for controlling this situation?

Thank you!
 
I

inventif

Thanks, Jeff, I certainly will.

Cheers!


Jeff Boyce said:
I urge you to investigate Duane H's AtYourSurvey ... it provides an
excellent approach to building Access-based questionnaires/surveys:

http://www.rogersaccesslibrary.com/OtherLibraries.asp#Hookom,Duane

Regards

Jeff Boyce
Microsoft Office/Access MVP

inventif said:
Thank you, Jeff, you were spot on. Worked like a charm from the first
attempt.

And, yes, I am building a very simple query (one page, 20-ish questions),
being used to "copy" a paper survey into a digital format for easier data
analysis.

Cheers!

Jeff Boyce said:
In your option group's AfterUpdate event, you could add something like
(untested):

If Me!YourOptionGroupName = 99 Then
Me![Q1 other].Visible = True
Else
Me![Q1 other].Visible = False
End If

You'd also need to make sure that when an existing record was loaded into
the form (check the OnCurrent event), that same code fired again. You
could
use something like (also untested):

Call YourOptionGroupName_AfterUpdate()

By the way, and I may be reading too much into the field names you used,
if
this is related to a questionnaire/survey (I saw Q1 and thought "question
1"), you may want to post a description of your underlying table
structure
to the tablesdbdesign newsgroup to see if there are alternate approaches
...
surveys can be tricky.

By the way, #2 -- use YOUR field names, not the generic ones I wrote
above.

Regards

Jeff Boyce
Microsoft Office/Access MVP


Hi,

I have an option group with 5 selections. The last one is "Other" and
it
pumps a value of 99 into the underlying field (called Q1).

I would like to display (make visible) another field (called Q1other)
when
"Other" (99) is selected from the option group.

I've tried a few combinations of events, even looked at conditional
formatting and nothing seemed to work.

Which event should I use to trigger this behaviour? Also, what code
would
you suggest for controlling this situation?

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