473,700 Members | 2,792 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reference textbox of subform in VBA

Hi all !!
i have met trouble with referring textbox of subform in VBA
i know i can do as: forms!mainform. subform.textbox
but i want do it in shorter path.
any suggestion about using variable ?
Pls help me !!
many with thanks !
Sep 16 '06 #1
3 38859
"luanhoxung " <lu********@yah oo.comwrote
i have met trouble with referring textbox
of subform in VBA
i know i can do as: forms!mainform. subform.textbox
but i want do it in shorter path.
any suggestion about using variable ?
If the VBA is in the module of the main form, you can use the "Me" notation
for currently-active form, as

Me!SubformContr olName.Form.Tex tBox

I would NOT expect the format you show to work, but that might depend on
what you mean by "subform", as there is no "Subform" object in Access --
there is a Subform Control, into which a Form may be embedded.

The correct form for VBA in a standard Module (not the Form's Module),
would, in fact, be

Forms!MainFormN ame!SubformCont rolName.Form!Te xtBox

If you have repeated references to the TextBox, you might use

Dim tb as TextBox

Set tb = Forms!FormName! SubformControlN ame.Form!TextBo xName

and then use the Object Variable tb to refer to the Text Box, if all you
want to do is shorten the references... you will have to make the design
tradeoff of whether it is, in fact, more efficient to do it that way.

Larry Linson
Microsoft Access MVP
Sep 16 '06 #2
hi Larry and all !!
i got the great result from ur help. 'thanks alot'
but i also get a new trouble with my project.
My english is not good, so my interpretation is not clear.
In my project i have 2 forms:
main form: F1 base on table: T1 with MAHH is primary key.
sub form: F2 base on table: T2 with MAHH is foreign key.
F1 and F2 link by a button(ToggleLi nk)
my goal is when i type a text in MAHH of F1
after that when i click on Togglelink to open F2, i also get the value in
columns MAHH of F2(new record) that are the same text MAHH of F1.
but it don't do as my mind.
Pls show me ur idea abt this.
if u can't understand, i will explain more clearly about my database.
because my data in vietnamese, so i can't show all.
thanks.
Sep 16 '06 #3
"Larry Linson" <bo*****@localh ost.notwrote in
news:RVLOg.960$ wU4.174@trnddc0 6:
If the VBA is in the module of the main form, you can use the "Me"
notation for currently-active form, as

Me!SubformContr olName.Form.Tex tBox
Seems rather odd that you'd use a ! for the subform control and a .
for the textbox. I'd think you'd use either:

Me.SubformContr olName.Form.Tex tBox

OR:

Me!SubformContr olName.Form!Tex tBox

I'd certainly use the latter (I never use the . for references to
controls).

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
Sep 16 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
24844
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that contains the subform is named Clients. I have this code in the Add Client btn: If Forms!Clients.subformVisits!VisitDirty = True Then MsgBox "Visit subform is dirty!"
1
1529
by: deko | last post by:
Dim frm as Form Set frm = Forms!frmMain!frmSub1.Form!frmSub2 Can I do this? I can't seem to get this to work... What is correct syntax? -- or how about -- Dim ctl as Control Set ctl = Forms!frmMain!frmSub1.Form!frmSub2.Form!Myctl
1
3074
by: Sam Phillips | last post by:
Howdy, I'm trying to apply color schemes to forms and subforms. I'm using a global function to change the colors/fonts of controls. Right now it correctly loops over the controls in the main form, what I want is recursive behavior to format the subforms. Here's a sketch: Function ApplyColorScheme(strFormName As String)
12
19008
by: MLH | last post by:
I have created two forms: frmBrowseNegsMainform and frmBrowseNegsSubform. I put a subform control on the first of these. The SourceObject property for the subform control is, of course, frmBrowseNegsSubform. I would like to perform an ascending or descending sort on any of the 7 columns shown in datasheet view in the subform control. I've been unsuccessful. Is there something tricky about sorting in subform controls?
1
2941
by: sofakingfree | last post by:
I keep getting an invalid property assignment error when tring to reference a subform. All I am trying to do is substitute this: Forms!!.SetFocus for this: FormAndSubForm.SetFocus
5
2618
by: ApexData | last post by:
My popup form can reference the MAINFORM by using either line of the code shown below: -------------------------------------------------------------------------------- ("F-PERS").Controls("cboEduc").Requery 'My reference using hidden text boxes. (txtFormName).Controls(txtComboName).Requery --------------------------------------------------------------------------------
1
1583
by: jschmidt | last post by:
Hello, I have an inventory/ordering database I have been working on for some time now and I have some accross a part that I am not sure how to deal with. I am using access 2003 for this database. I have a main form where the user is able to enter the shipping and po number and ... ... on the main form there is also a subform which allows the user to select the products that they need to include for the order. On the subform the user can...
3
1514
by: ntabb | last post by:
I'm writing a function to cut the information out of a textbox when a button is pressed. There are many textboxes on the form, and I only want to cut the information in the box that has the cursor. I really don't want to look for the cursor in each textbox in each level of the form. Is there a way to reference the "current" textbox? Thanks, NT
0
8638
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9058
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8952
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8909
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6555
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5894
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4649
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2371
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2018
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.