I'd suggest assigning the values of the various address controls on the
frm_shipping parent form to the DefaultValue properties of the corresponding
controls on the subform. If you want to automate this put the code in the
Current event procedure of the parent form AND in its AfterInsert event
procedure. If you want to do it manually put it in the Click event procedure
of a button on the parent form. The code would be something like this:
Me.sfrBillings.Form.Ad1.DefaultValue = """" & Me.Ad1 & """"
Me.sfrBillings.Form.Ad2.DefaultValue = """" & Me.Ad2 & """"
Me.sfrBillings.Form.Ad3.DefaultValue = """" & Me.Ad3 & """"
Me.sfrBillings.Form.Ad4.DefaultValue = """" & Me.Ad4 & """"
A few things you need to realize:
1. sfrBilling is the name of the subform *control* on the frm_shipping
parent form, i.e. the control which houses the subform, not its underlying
form object, frm_billing (unless the control and its underlying form object
have the same name of course).
2. Assigning a value as the DefaultValue property of a control only sets
the value which will be automatically entered when you add a new record in
the subform. Although the values will show in a blank record in the subform
the record won't begin to be created until you add other data or change any
of the default values.
3. If you use a button to set the default values manually the values you
set in one shipping record will carry over when you move to another shipping
record while the form is still open, until you click the button again.
Automatic assignment of the values in the Current and AfterInsert event
procedures of the parent form would probably be a better strategy therefore.
4. The DefaultValue property is always a string expression, regardless of
the underlying data type of the field in question, which is why the values
are wrapped in quote characters in the above code with the two sets of """".
A double set of quotes within a string delimited by quotes is interpreted by
Access as a literal quotes character. Often these quotes aren't absolutely
necessary, but can sometimes be crucial in circumstances where you might not
expect them to be needed (date/time values for instance), so its good
programming practice to always include them in your code.
Ken Sheridan
Stafford, England
Ultraviolet47 said:
Hi all
I have frm_shipping based on tbl_shipping where there are address
fields. I also have a subform, frm_billing based on tbl_billing in this
that's for billing details, as they may not be the same.
I would like a button so that I can automatically copy the details from
frm_shipping to sub form frm_billing if they are the same.
Following suggestions on here I've tried insert into and things like
Frm_billing![Ad1]=Frm_shipping![Ad1], etc but no luck?
Can someone point me int he right direction please? Using Access 2003
Greatly appreciated, thank you.