How to populate a control from one of a number of forms that might be open

  • Thread starter Thread starter Barr
  • Start date Start date
B

Barr

I would like to populate a control in form B with a value from a control
with a common name in say 5 different forms (A1-A5), the one form I am using
(A1-A5), should determine what to populate the new one (form B) with when I
open form (command button). How do I refer to the control on the first form
(say A4 for example) on the second form (form B) which has a different name
cause it comes from one of five different forms?
 
well, it's not clear whether you're opening form B from an already-open
A-series form, or vice versa. i'll assume that an A-series form is open, and
you're opening form B from it. one solution is to use the OpenArgs argument
of the OpenForm code in the A-series forms, as

DoCmd.OpenForm "FormB", , , , , , Me!SomeControlName

then refer to the OpenArgs property of form B, in its' Load event, to set
the value of the control, as

Me!SomeControlName = Me.OpenArgs

note that the value of the OpenArgs property is a string. if you get a "type
mismatch" error, you'll probably have to coerce the value to the appropriate
data type with a conversion function such as CDate(), CLong, etc.

hth
 
Back
Top