Reading a value in another subform

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

Guest

I have a form with two subforms in it, and I'm trying to get the second
subform to read a value from the first subform, and I'm wondering if anyone
here might have a handle on it.

The situation: In the second subform, you select OTR (Over the road) or Rail
for method of transport. When you go to the next field, Receive Date, it
should look at the value in the first subform for either OTR or Rail, and add
that number of days to the Ship Date (in 2nd form) to show you the date the
shipment will arrive.

I'm using the On Enter area so the user can select transport type, and get
the right info when they click into the field. It basically says, if user
selected OTR, look in the 1st subform for the value of OTR and add that, else
it looks in the Rail value and adds that # of days.

The expression I'm using is (I've tried normal quotes around OTR also):
=IIf([ShipType]='OTR',[RecvDate]=[RecvDate]+[Forms]![Form-Main]![Form-Main_Sub-LocationInfo].[OTR],[Forms]![Form-Main]![Form-Main_Sub-LocationInfo].[Rail])

It's like that when I enter it, but after I've tried it, it removes some
important looking brackets to come up like this:
=IIf([ShipType]='OTR',[RecvDate]=[RecvDate]+Forms![Form-Main]![Form-Main_Sub-LocationInfo].OTR,Forms![Form-Main]![Form-Main_Sub-LocationInfo].Rail)

The error I receive is:
The expression On Enter you entered as the event property setting produced
the following error: The object doesn't contain the Automation object 'OTR.'."

Any help at all would be very very appreciated!

Thanks!
Steph
 
You need to add the word "Form" after h=the sub form name, try this:

Yours
Forms![Form-Main]![Form-Main_Sub-LocationInfo].OTR

Should be
Forms![Form-Main]![Form-Main_Sub-LocationInfo].Form!OTR
 
Another thing, in the IIf you have "[RecvDate]=" why?

Yours:
=IIf([ShipType]='OTR',[RecvDate]=[RecvDate]+Forms![Form-Main]![Form-Main_Sub-LocationInfo].OTR,Forms![Form-Main]![Form-Main_Sub-LocationInfo].Rail)

did you mean:
[RecvDate]=IIf([ShipType]='OTR',[RecvDate]+Forms![Form-Main]![Form-Main_Sub-LocationInfo].Form!OTR,Forms![Form-Main]![Form-Main_Sub-LocationInfo].Form!Rail)
 
Why? Uhm *nervous titter* I believe the answer to that would be I'm falling
back on older knoweledge from other software. Access isn't brand new to me
any longer, but it still has a lot to teach me.

I can see what you're doing, and I will give it a shot. The 'false' part of
my expression, I believe, is wrong. Basically, it's to add the OTR value to
the date if OTR is chosen, and the Rail value if Rail is chosen (odd how that
all fits together huh? haha)

Thank you for your help! The first suggestion removed my error, and I will
see what happens with the second. Hang on a moment, I'll be right back.

....

Alas, I get #Error in the field with the equation. This is so odd to me, as
I've done this kind of thing before.

Ofer Cohen said:
Another thing, in the IIf you have "[RecvDate]=" why?

Yours:
=IIf([ShipType]='OTR',[RecvDate]=[RecvDate]+Forms![Form-Main]![Form-Main_Sub-LocationInfo].OTR,Forms![Form-Main]![Form-Main_Sub-LocationInfo].Rail)

did you mean:
[RecvDate]=IIf([ShipType]='OTR',[RecvDate]+Forms![Form-Main]![Form-Main_Sub-LocationInfo].Form!OTR,Forms![Form-Main]![Form-Main_Sub-LocationInfo].Form!Rail)

--
Good Luck
BS"D


Luna Saisho said:
I have a form with two subforms in it, and I'm trying to get the second
subform to read a value from the first subform, and I'm wondering if anyone
here might have a handle on it.

The situation: In the second subform, you select OTR (Over the road) or Rail
for method of transport. When you go to the next field, Receive Date, it
should look at the value in the first subform for either OTR or Rail, and add
that number of days to the Ship Date (in 2nd form) to show you the date the
shipment will arrive.

I'm using the On Enter area so the user can select transport type, and get
the right info when they click into the field. It basically says, if user
selected OTR, look in the 1st subform for the value of OTR and add that, else
it looks in the Rail value and adds that # of days.

The expression I'm using is (I've tried normal quotes around OTR also):
=IIf([ShipType]='OTR',[RecvDate]=[RecvDate]+[Forms]![Form-Main]![Form-Main_Sub-LocationInfo].[OTR],[Forms]![Form-Main]![Form-Main_Sub-LocationInfo].[Rail])

It's like that when I enter it, but after I've tried it, it removes some
important looking brackets to come up like this:
=IIf([ShipType]='OTR',[RecvDate]=[RecvDate]+Forms![Form-Main]![Form-Main_Sub-LocationInfo].OTR,Forms![Form-Main]![Form-Main_Sub-LocationInfo].Rail)

The error I receive is:
The expression On Enter you entered as the event property setting produced
the following error: The object doesn't contain the Automation object 'OTR.'."

Any help at all would be very very appreciated!

Thanks!
Steph
 

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

Back
Top