Copying contents of control on main form to control on subform

K

Kimberley523

I have a main form, frmClaim_Initial_Entry and a subform
sfrmClaimInfo_InitialEntrysubform. If the Insured Address is the same as the
loss location address, I want to copy the contents of the 4 insured address
fields from the main to the subform. I am testing with just one field and
will apply to the others once I have this working.

The name of the subform control in the main form is actually
sfrmClaimInfo_InitialSub, which I have tried unsuccessfully to use below.

I've tried the following code:

Forms!frmClaim_Initial_Entry!Insured_Address.SetFocus
DoCmd.RunCommand acCmdCopy

DoCmd.GoToControl Forms!frmClaim_Initial_Entry!sfrmClaimInfo_InitialSub.Form.
LossLocationStreet
DoCmd.RunCommand acCmdPaste

This gives me an error of:
Method 'Form' of object '_subform' failed

I have also tried the following:

Forms!frmClaim_Initial_Entry!sfrmClaimInfo_InitialSub.Form.
LossLocationStreet = _
Forms!frmClaim_Initial_Entry!Insured_Address

and I receive the same error message above.

Any assistance is SO welcome. If there is an easier way to do this, that
would be appreciated as well. Thanks in advance for your help.
 
S

Steve

If you think you need to copy contents of fields in a main form to fields in
a subform, your tables are incorrect. Post your tables for our review.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
K

Kimberley523

Steve, The database is for tracking claims for an insurance adjusting firm.
I've listed the relevant fields below. The two tables are linked in a one to
many relationship by policy number. One policy can have many claims.
Additionally, the insured may have more than one property, thus the two
addresses, "Insured Address" in tblPolicyInfo and "Loss Location Address" in
tblClaimsInfo.

If the addresses are the same, I would like to have the information copied,
this would be triggered by an "after update" or "on click" event when the
user clicks a check box field "Loss Location Same as Insured?" which is a
yes/no field, i.e., if the field is "yes", then copy the information. If
these two addresses are not the same, the user will need to enter the loss
location address in the subform.

The main form is based on the table below, tblPolicyInfo:

tblPolicyInfo (Main form is based on this)
===============================
Policy_Number - primary key
Insured_Name
Insured_Address
Insured_City
StateID - linked to states table (foreign key)
Insured_Zip

The subform is based on this table, tblClaimsInfo:
tblClaimInfo (Subform is based on this)
============================
ClaimID - primary key
PolicyNumber - linked to tblPolicyInfo (foreign key)
LossLocationStreet
LossLocationCity
LossLocationState - linked to states table (foreign key)
LossLocationZip
LossLocSameasIns?

Please let me know if this info is sufficient.
If you think you need to copy contents of fields in a main form to fields in
a subform, your tables are incorrect. Post your tables for our review.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
I have a main form, frmClaim_Initial_Entry and a subform
sfrmClaimInfo_InitialEntrysubform. If the Insured Address is the same as
[quoted text clipped - 30 lines]
Any assistance is SO welcome. If there is an easier way to do this, that
would be appreciated as well. Thanks in advance for your help.
 
S

Steve

Yes, the issue is very clear now, thanks!

My recommendation is that you do not want to put the insured's address,
city, state and zip in the subform fields when you check LossLocSameasIns.
Two reasons, first if you do and later learn that they are different, you
got to have a mechanism for deleting and or changing the loss location
fields in tblClaimInfo; second, if you do and later discover an error in
the insured's info, you would have to go to tblClaimInfo and make the
correction there too. I suggest in your design of tblClaimInfo you make the
default value of LossLocSameasIns True and then in the design of your
subform you disable LossLocationStreet,
LossLocationCity, LossLocationState and LossLocationZip. Then put the
following code in the AfterUpdate event of LossLocSameasIns:
If Me!LossLocSameasIns = False Then
Me!LossLocationStreet.Enabled = True
Me!LossLocationCity.Enabled = True
Me!LossLocationState.Enabled = True
Me!LossLocationZip.Enabled = True
Else
Me!LossLocationStreet = Null
Me!LossLocationCity = Null
Me!LossLocationState = Null
Me!LossLocationZip = Null
Me!LossLocationStreet.Enabled = False
Me!LossLocationCity.Enabled = False
Me!LossLocationState.Enabled = False
Me!LossLocationZip.Enabled = False
End If

In the above code, if you uncheck LossLocSameasIns, the four location loss
fields will be enabled for you to enter the loss address and if
LossLocSameasIns is unchecked and you check it, the data in the four
location loss fields will be erased and the four location loss fields will
be disabled so you can not enter data into the location loss fields.

You also need code in the Current event of your form to enable or disable
the four location loss fields:
If Me!LossLocSameasIns = False Then
Me!LossLocationStreet.Enabled = True
Me!LossLocationCity.Enabled = True
Me!LossLocationState.Enabled = True
Me!LossLocationZip.Enabled = True
Else
Me!LossLocationStreet.Enabled = False
Me!LossLocationCity.Enabled = False
Me!LossLocationState.Enabled = False
Me!LossLocationZip.Enabled = False
End If

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)







Kimberley523 said:
Steve, The database is for tracking claims for an insurance adjusting
firm.
I've listed the relevant fields below. The two tables are linked in a one
to
many relationship by policy number. One policy can have many claims.
Additionally, the insured may have more than one property, thus the two
addresses, "Insured Address" in tblPolicyInfo and "Loss Location Address"
in
tblClaimsInfo.

If the addresses are the same, I would like to have the information
copied,
this would be triggered by an "after update" or "on click" event when the
user clicks a check box field "Loss Location Same as Insured?" which is a
yes/no field, i.e., if the field is "yes", then copy the information. If
these two addresses are not the same, the user will need to enter the loss
location address in the subform.

The main form is based on the table below, tblPolicyInfo:

tblPolicyInfo (Main form is based on this)
===============================
Policy_Number - primary key
Insured_Name
Insured_Address
Insured_City
StateID - linked to states table (foreign key)
Insured_Zip

The subform is based on this table, tblClaimsInfo:
tblClaimInfo (Subform is based on this)
============================
ClaimID - primary key
PolicyNumber - linked to tblPolicyInfo (foreign key)
LossLocationStreet
LossLocationCity
LossLocationState - linked to states table (foreign key)
LossLocationZip
LossLocSameasIns?

Please let me know if this info is sufficient.
If you think you need to copy contents of fields in a main form to fields
in
a subform, your tables are incorrect. Post your tables for our review.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
I have a main form, frmClaim_Initial_Entry and a subform
sfrmClaimInfo_InitialEntrysubform. If the Insured Address is the same
as
[quoted text clipped - 30 lines]
Any assistance is SO welcome. If there is an easier way to do this,
that
would be appreciated as well. Thanks in advance for your help.
 
G

Guest

The syntax varies with your point of view: main (parent) form or sub (child
form).

In your case, you might have command button on sub-form that can pull values
from main form text boxes using syntax such as (an example):

=Forms("ShipOne")![mTONS] 'this is on subform

or, Forms(MainFormName)![NameofControlOnMainForm]

In other words, to set a value on the subform, pulling from main form, using
command on subform, might be something like:

.... On_Click

[SubFormControlName] = Forms(MainFormName)![NameofControlOnMainForm]


To go the other way (from Main Form point of view), you can refer to a
control on a subform using syntax such as:


Forms![MainFormName]![NameOfSubForm]![NameOfControlOnSubForm]
 

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