Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Referencing a Control on Another Form

Status
Not open for further replies.

Tranz2

Programmer
Jan 2, 2003
18
US
I'm working with packaged software where there the form I'll call frmExample consists of 2 headers and 2 details, called Header0, Header1, Detail1, Detail0. The CustomerID field on Detail1 is bound to the tblCustomer table, and the FinanceChargeAmount field on Detail0 is bound to the tblInvoice table.

The customer ID is typed in or selected from a drop-down list. What I want to do is make FinanceChargeAmount.Visable either true or false based on a bit field in the Invoice table, called FinChgYn. The problem is, there is no "event" on Detail0 upon which to:

If Me.FinChgYn = False Then
Me.FinanceChargeAmount.Visible = False
End If

There is a property of the CustomerID field on Detail1 called On Change, and I've confirmed that it fires when the customer ID changes. I put the above code in the code builder section called "Public Sub CustomerID_Change()". The problem is it will not recognize that the FinanceChargeAmount field exists, probably because the event is on Detail0 and not Detail1.

My question is, how do I reference the FinanceCharge field on Detail0 from Detail1? Is it possible to do? I have tried various things, such as Detail0.FinanceChargeAmount, but none of them work.
 
I want to correct something about my last post. I'm not talking about referencing a control on a diffent form, I'm talking about referencing a control on a different SECTION of the same form. Detail0 and Detail1 are names of sections on the form frmExample. I've tried the following syntax, and get the error "Application defined or object defined error":

Forms!frmExample.Detail0.FinanceChargeAmount.Visible = False
 
Some information I can add is that this is an Access 2003 project - it has an extension of .adp. When I right-click the frmExample, and click Design View, I see a form with a grey band that says "Form Header" Below that, there is a grey band that says "Detail". Below that is a grey band that says "Form Header". And below that is a grey band that says "Detail". Each of these 4 sections have controls on them.
 
Yes, there is a subform - it works in a mirrored fashion to the original - but I'm new at this and don't really understand it well enough to "rephrase" it. I've actually presented a simplified example to illustrate the basic problem - I need to change the property of one control when the contents of another control changes, but it can't find or recognize the control whose properties I want to change. If you'd like, I could email or perhaps upload to you the zipped adp, with an explanation of the 2 controls in question. I have a feeling it's either something very simple, or it's impossible to do.
 
I'm so glad you responded and mentioned subforms. I learned a little about them, and dug around for the right syntax, and came up with something that works. For the example I presented, it would be:

Forms!frmSample!frmSampleSub.Form.FinanceChargeAmount.Visible = False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top