Reference a field on a subform on a tab control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I posted this in "access forms" rather than here. Sorry.

I have a form called 'Tabs'. On this form I have a two page "Tab Control".
On "Page1" I have a form called 'Bank'. On the 'Bank' form I have a field
called 'Creditor'.

On the original 'Bank' form, I have the following working code:

If Forms![Bank]![Creditor] = False Then
[Debit_Label].Caption = "Debits"
[Credit_Label].Caption = "Credits"
Else
[Debit_Label].Caption = "Charges"
[Credit_Label].Caption = "Payments"
End If

I have moved the 'Bank' form to the 'Page1' tab of the 'Tab Control'. When I
open the 'Tabs' form, the codes fails and reports that it can't find the
field 'Bank'.

How do I reference the field 'Creditor' which is now on a tab control called
page1 in a form called 'Bank'?
 
Bank is a subform on Tabs.
From Tabs, Use:
Me!Bank!Creditor
From Bank, use:
Me!Creditor
 
I posted this in "access forms" rather than here. Sorry.

I have a form called 'Tabs'. On this form I have a two page "Tab Control".
On "Page1" I have a form called 'Bank'. On the 'Bank' form I have a field
called 'Creditor'.

On the original 'Bank' form, I have the following working code:

If Forms![Bank]![Creditor] = False Then
[Debit_Label].Caption = "Debits"
[Credit_Label].Caption = "Credits"
Else
[Debit_Label].Caption = "Charges"
[Credit_Label].Caption = "Payments"
End If

I have moved the 'Bank' form to the 'Page1' tab of the 'Tab Control'. When I
open the 'Tabs' form, the codes fails and reports that it can't find the
field 'Bank'.

How do I reference the field 'Creditor' which is now on a tab control called
page1 in a form called 'Bank'?

The Tab Control is irrelevant to the naming convention, as is the name
of the Form being used in the subform.

What you need to use is the Name property *of the subform control*
containing the Bank form. It might be Bank, it might be something else
- select the subform control by clicking the edge, so just the
"handles" are highlighted, not the form within the control, and view
its properties to get the name.

The correct syntax is

[Forms]![mainform]![subformcontrol].Form![controlname]

If the code is on the main form, the Forms![mainform] can be replaced
with the shortcut Me!: e.g.

Me![Bank].Form![Debit_Label].Caption = ...

John W. Vinson[MVP]
 
The following better explains what I need to do.

Bank --- has the field '[Creditor]'

Bank Transactions --- has the fields [Debit_Label] and [Credit_Label]

Bank Transactions needs to look at Bank to get the status of '[Creditor]'
which is either True or False. If [Creditor] is False, then [Debit_Label] is
set to "Debits" and [Credit_Label] is set to "Credits otherwise [Debit_Label]
is set to "Charges" and [Credit_Label] is set to "Payments".

Bank Transactions is a subform of Bank.

Bank Transactions is where the 'processing' is being done.

Bank & Bank Transactions are on 'Page1' of a Tab Control.

My programming works okay for what I am doing but I want to take advantage
of the 'Tab Control' feature instead of using a menu based form.

--
signed

Dave, Regina SK


PC Datasheet said:
Bank is a subform on Tabs.
From Tabs, Use:
Me!Bank!Creditor
From Bank, use:
Me!Creditor

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com


David said:
I posted this in "access forms" rather than here. Sorry.

I have a form called 'Tabs'. On this form I have a two page "Tab Control".
On "Page1" I have a form called 'Bank'. On the 'Bank' form I have a field
called 'Creditor'.

On the original 'Bank' form, I have the following working code:

If Forms![Bank]![Creditor] = False Then
[Debit_Label].Caption = "Debits"
[Credit_Label].Caption = "Credits"
Else
[Debit_Label].Caption = "Charges"
[Credit_Label].Caption = "Payments"
End If

I have moved the 'Bank' form to the 'Page1' tab of the 'Tab Control'. When
I
open the 'Tabs' form, the codes fails and reports that it can't find the
field 'Bank'.

How do I reference the field 'Creditor' which is now on a tab control
called
page1 in a form called 'Bank'?
 
The following better explains what I need to do.

Bank --- has the field '[Creditor]'

Bank Transactions --- has the fields [Debit_Label] and [Credit_Label]

Bank Transactions needs to look at Bank to get the status of '[Creditor]'
which is either True or False. If [Creditor] is False, then [Debit_Label] is
set to "Debits" and [Credit_Label] is set to "Credits otherwise [Debit_Label]
is set to "Charges" and [Credit_Label] is set to "Payments".

Bank Transactions is a subform of Bank.

Bank Transactions is where the 'processing' is being done.

Bank & Bank Transactions are on 'Page1' of a Tab Control.

This isn't making sense.

If Bank and Bank Transactions are both Subforms, that contradicts your
statement that Bank Transactions is a subform of Bank!

If it *is* a subform, then the Tab Control is irrelevant. You should
be able to put code in the Bank Transactions form's Current event such
as:

Private Sub Form_Current()
If Parent![Creditor] Then
Me!Debit_Label.Caption = "Charges"
Me!Credit_Label.Caption = "Payments"
Else
Me!Debit_Label.Caption = "Debits"
Me!Credit_Label.Caption = "Credits"
End If
End Sub

John W. Vinson[MVP]
 

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

Back
Top