Referencing a Control on Another Form

B

BobRoberts

I'm working with packaged software where the form I'll call frmExample
consists of 2 headers and 2 details, called Header0, Header1, Detail1,
Detail0. The CustomerID field (a combobox) 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 Detail1 and the control is on
Detail0.
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.
 
J

Jack Leach

You have two forms (according to the post's subject)? But you describe one
form with two headers and details and two seperate record sources? Is this
possible? Am I missing some sort of new functionality with the newer
versions?

FWIW, to reference a control on a seperate form (assuming it's open,
obviously), the syntax is one of these two:

Forms!FormName!ControlName

or

Forms("FormName").Controls("ControlName")


I've very curious about this frmExample that is two forms in one...

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
B

BobRoberts

Jack said:
You have two forms (according to the post's subject)? Am I missing some sort of new functionality with the newer
versions?


Thank you for responding. It was my error in terminology. It's an Access
2003 project (.adp). There's one form object, but 4 form SECTIONS. I should
have used the word section in referring to Detail0 and Detail1. I've tried
the following syntax, but get an "Application defined or object defined error.
":


Forms!frmExample.Detail0.FinanceChargeAmount.Visible = False
 
J

Jack Leach

Ahhh, I see... alas I have no experience with adps, and was not aware that
you could have more than three (header, detail, footer) sections per form.

Someone else will have to take this one...

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
B

BobRoberts

Jack said:
Ahhh, I see... alas I have no experience with adps, and was not aware that
you could have more than three (header, detail, footer) sections per form.

Someone else will have to take this one...

All I really need to do is to get an event to fire on Detail0 when the
CustomerId changes on Detail1. The After Update property of CustomerId on
Detail1 is:
"=genfindrecord("CustomerID","CustomerID",0)"

I tried creating a text box on Detail0 with a name of CustomerIdChange and a
control source of CustomerId, and it does change when the Detail1 customer Id
changes, but its On Change event does not fire when the underlying SQL value
changes.

I wonder if there is some way to temporarily switch the active section to
Detail0, make the .Visible changes, and then switch it back to Detail1 - this
done within the code of the On Change event of Detail1.CustomerId.
 
B

BobRoberts via AccessMonster.com

I dug a little deeper, and discovered that the "other form" was actually a
subform. I found this syntax, and it works for my purposes:

Forms!frmSample!frmSampleSub.Form.FinanceChargeAmount.Visible = False
 

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