change value of control in subform based on value in another subfo

J

jacchops

Previously I had a form that combined information from a couple different
tables. This form was long, and whenever the users used their scroll button
to scroll down the form, the records would cycle as opposed to the form
scrolling.

So instead of using one long form, I am designing a new form with a tab
control and a subform on each tab.

When a user selects "Yes" from the drop-down of Contol 1 in Subform 1 on Tab
Page 1, I want value of Control 2 in Subform 2 on Tab Page 2 to automatically
to be set to "N/A" (which is an option in the drop down for Control 2).

Previously, when Control 1 and Control 2 were on the same form, I had a
"Select Case..." VB code for the After Update event procedure for Control 1
that looked like this:

Select Case Control_1.Value
Case "Yes"
Control_2.Value = "N/A"
End Select

How do I do this when Control 1 and 2 are on different subforms?
 
S

Steve Schapel

Jacchops,

You have posted your question to a Macros forum, but since you have
quoted VBA procedure, I will assume you wish to continue using VBA
rather than macro for this.

If Me.Control_1 = "Yes" Then
Me.Parent!Subform_2.Form!Control_2 = "N/A"
End If

Just wondering... if the user enters "Yes" in Control_1, and then
subsequently changes it to something else, do you have that covered?
 
J

jacchops

Thank you for the quick response, and sorry for posting this in the wrong
discussion group. I did want to use VBA.

What does "Me" represent?

If the user changes their response in Control_1 from "Yes" to "No", I am
planning on having a message box pop up reminding them to change their
Control_2 response accordingly (which I have yet to tackle logistically), but
by default, I want the Control_2 to stay as "N/A". (These control names and
responses are arbitrary for this post's purpose, but in actuality it's best
if the original answer for Control_2 remains, since the users sometimes
accidentally change the response to Control_1, and I don't want that accident
to erase the original (and probably correct) response in Control_2.)
 
S

Steve Schapel

Jacchops,
What does "Me" represent?

"Me" is a keyword that refers to the active object. It is commonly used
when referring in VBA code to fields or controls on the same form or
report from which the code is running.
... These control names and
responses are arbitrary for this post's purpose

Generally this is not a good idea. I realise that you probably think it
simplifies your question to the simplest elements. But in practice,
your chances of getting good help are increased when you can paint an
accurate picture of what you are working with.
 

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