UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Syntax For Referencing A Textbox On A Subform, Access 2010    
 
   
projecttoday
post Dec 7 2017, 12:18 AM
Post#1


UtterAccess VIP
Posts: 8,674
Joined: 10-February 04
From: South Charleston, WV


Does anybody know the correct syntax for referencing a textbox on a subform in a main form? The textbox in question is in the footer section of the subform. I tried Me.Subformname.Form.Controlname but that didn't work.

The attached db is the one where this came up in another thread. Form2 contains 2 subforms, 1 for debits. 1 for credits. We are trying to calculate the balance of total debits minus total credits. I'm using Dsum's but I'd rather reference the subforms.
Attached File(s)
Attached File  subformtest.zip ( 41.09K )Number of downloads: 7
 

--------------------
Robert Crouser

My company's website
Go to the top of the page
 
HairyBob
post Dec 7 2017, 04:14 AM
Post#2



Posts: 875
Joined: 26-March 08
From: London


Hi Robert,

Try:

CODE
Me.[Receipts Form].Form.txtDrSum


And:

CODE
Me.[Payment Form].Form.txtCrSum


Where [Receipt Form] and [Payment Form] are the Sub Control names.

HTH...

Hairy.
This post has been edited by HairyBob: Dec 7 2017, 04:15 AM

--------------------
If it was easy, It wouldn't be fun!
Go to the top of the page
 
projecttoday
post Dec 7 2017, 07:42 AM
Post#3


UtterAccess VIP
Posts: 8,674
Joined: 10-February 04
From: South Charleston, WV


As I stated in my post, I've already tried that. If you've done it this way and it works, then please post it.

--------------------
Robert Crouser

My company's website
Go to the top of the page
 
BruceM
post Dec 7 2017, 07:57 AM
Post#4


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


If referencing it by using an expression in the text box Control Source the Me syntax won't work since that is VBA only. This worked for me as Control Source expressions:

=[Forms]![Form2]![Receipts Form].[Form]![txtDrSum]
=[Forms]![Form2]![Payment Form].[Form]![txtCrSum]

If those text boxes are named txtDrTotal and txtCrTotal you can have another text box to sum those:

=[txtDrTotal] + [txtCrTotal]

I assume you are not trying to use VBA, since I don't see any code in the sample database. If you are trying to use VBA, more information is needed.
Go to the top of the page
 
Scott McDaniel
post Dec 7 2017, 08:00 AM
Post#5


UtterAccess VIP
Posts: 588
Joined: 18-February 09
From: North Augusta, SC


You can use this:

Me.FormFooter.Controls("txtcrsum")

Or the full reference to the form:

Forms!YourForm.FormFooter.Controls("txtcrsum")

--------------------
Go to the top of the page
 
mike60smart
post Dec 7 2017, 09:04 AM
Post#6


UtterAccess VIP
Posts: 12,350
Joined: 6-June 05
From: Dunbar,Scotland


Hi Robert

See the attached

Attached File  subformtest.zip ( 51.56K )Number of downloads: 7

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
BruceM
post Dec 7 2017, 09:22 AM
Post#7


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


Yes, that is the same as my suggestion, except I mistakenly showed addition rather than subtraction with credits and debits.
Go to the top of the page
 
projecttoday
post Dec 7 2017, 09:25 AM
Post#8


UtterAccess VIP
Posts: 8,674
Joined: 10-February 04
From: South Charleston, WV


Thanks to all who posted. The solution proposed by Bruce works. (I have used this in the past, I just couldn't remember it.) Thanks to all who posted.

--------------------
Robert Crouser

My company's website
Go to the top of the page
 
HairyBob
post Dec 7 2017, 10:04 AM
Post#9



Posts: 875
Joined: 26-March 08
From: London


Hi Robert,

Looks like Mike & Bruce beat me to it; however, here's what I did to test it (see attachment). Apologies for not posting the attachment in the first place.

Regards,

Hairy.
Attached File(s)
Attached File  subformtest2.zip ( 49.1K )Number of downloads: 1
 

--------------------
If it was easy, It wouldn't be fun!
Go to the top of the page
 
BruceM
post Dec 7 2017, 10:10 AM
Post#10


UtterAccess VIP
Posts: 7,022
Joined: 24-May 10
From: Downeast Maine


Glad to hear it. Good luck with the project.
Go to the top of the page
 
projecttoday
post Dec 7 2017, 10:58 AM
Post#11


UtterAccess VIP
Posts: 8,674
Joined: 10-February 04
From: South Charleston, WV


Thanks, Hairy.

--------------------
Robert Crouser

My company's website
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    12th December 2017 - 03:14 AM