472,378 Members | 1,337 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

How to reference text box values on different form

114 100+
Have a need to reference a value in 1 or 2 text box(s) on a prior form. Based on the value(s) entered, I may need to clear out 1 or 2 value(s) that where entered but not required in a couple of text boxes on the prior form.

Not sure how to reference those text boxes in the dot notation used in VBA. I tried to use the Me.Refresh but that is not working. Is the Me. used to indicate the current working form?
Dec 28 '06 #1
7 77224
ADezii
8,832 Expert 8TB
Have a need to reference a value in 1 or 2 text box(s) on a prior form. Based on the value(s) entered, I may need to clear out 1 or 2 value(s) that where entered but not required in a couple of text boxes on the prior form.

Not sure how to reference those text boxes in the dot notation used in VBA. I tried to use the Me.Refresh but that is not working. Is the Me. used to indicate the current working form?
'To refer to a value in a Text Box named txtTest on frmTest from another Form,
'you can use this syntax:

Expand|Select|Wrap|Line Numbers
  1. Forms![frmTest]![txtTest].Text
Dec 28 '06 #2
ljungers
114 100+
'To refer to a value in a Text Box named txtTest on frmTest from another Form,
'you can use this syntax:

Expand|Select|Wrap|Line Numbers
  1. Forms![frmTest]![txtTest].Text
I tried this in my VBA script just before I perform a DoCmd.OpenForm stDocName, , , stLinkCriteria

have loaded the form name in stDocName after testing a couple of variables and based on that test I need to clear the values before that form is used again. Here is what I did but I'm getting the following error when I run it.

"You can't reference a property or method for a control unless the control has focus"

Forms![MemoLukupForm]![WhatLastName].Text = ""
Forms![MemoLukupForm]![WhatFirstName].Text = ""
Forms![MemoLukupForm]![WhatRecNo].Text = ""
Dec 28 '06 #3
ljungers
114 100+
Anyone know how I can accomplish this.
Dec 29 '06 #4
I came across this today for a similar problem

it's for the Value Property

The Text property returns the formatted string. The Text property may be different than the Value property for a text box control. The Text property is the current contents of the control. The Value property is the saved value of the text box control. The Text property is always current while the control has the focus.
try the .value instead of the .text see if that works

I was getting data though, not changing it
Dec 29 '06 #5
ljungers
114 100+
The .Value instead of .Text works, and the text boxes are clearned prior to returning to the 1st form.

Now the problem I'm having is after keying in new data in these cleared text boxes and clicking the button labeled "Search" that uses OnClick "LukupQuery".

The query seems to return nothing because a list box that uses that query results RowSourceType = table/query and RowSource = LukupQuery is now empty.

I have also noticed that my Query SQL window and the 2nd form window with the list box remain open.

Looks like something is not being done. Can some one tell me when, where and how a Refresh, Requery should be done? Should I be closing the 2 windows (query sql, 2nd form) if so, what is the VBA code to do just that.

Thanks
Dec 29 '06 #6
The .Value instead of .Text works, and the text boxes are clearned prior to returning to the 1st form.

As I am in no way an expert, could a expert confirm that the .Value is a good way to get past the "can't reference a control error?"
Dec 29 '06 #7
NeoPa
32,511 Expert Mod 16PB
It is, but a better way is simply to reference the control (.Value is the default property).
The OP doesn't specify what he means by the 'prior form', so we can only assume that it is a currently open form but not directly related to the current form (Me). In that case Forms!FormName.ControlName is a perfectly usable way to access the control.
Forms is another way of saying CurrentDB.Forms and Forms!FormName is another way of saying Forms.("FormName").
Dec 30 '06 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: iggie | last post by:
Hello, everyone. How can I display text from another form that currently has the focus. I'm doing a search in sql 2000, to dot it. I call a search form and query my criteria, when it founds the...
3
by: ChadDiesel | last post by:
I'm new to Access and need some advice. I am trying to setup a database to print labels and reports for our shipments. I have set up a table with fields such as I have taken a snapshot of what...
1
by: ChadDiesel | last post by:
I'm new to access and need some help. I have a form with a shipment destination at the top. I then have a subform that I enter boxes for that shipment. I have several shipments going at a...
14
by: rgreen3 | last post by:
Form1 is a PUBLIC class with a button, a label, and a PUBLIC method called AddText() Form2 is a PUBLIC class with a button When Form1.button is pressed it opens Form2 using the Show method The...
2
by: Aaron | last post by:
Hello, I have a textbox(txtFines) on one form(frmMain) that needs to have the text moved too a different form(frmFines) in a textbox(txtFineList) on btnDone_Click function. I know how to...
3
by: Ali | last post by:
I have 3 html input tex in my asp.net form. Two of them are calling javascript client side to calculate the differnce of two dates and put the result into the third input text. i haven't include...
16
by: Adda | last post by:
If I cycle through the MdiChildActivate event of the parent form I can read text in a textbox on the child mdiform -- console.writeline(Me.ActiveMdiChild.Controls(1).Text) But if I have a sub...
11
by: joey.powell | last post by:
Hello, I have a windows forms application (VS2005) where I need to do the following... 1. Startup with a main form. 2. Have the user to select a file and then bring up a second form modally...
1
by: romerve | last post by:
Hello; i am having some problems trying to get a form that has a datagridview to refresh after a new record is created. I have a MDI container and menu form and add new record form; the menu...
2
by: Fred | last post by:
I have two forms, the first having a label and a button that opens the second form. The second form has a button that I want to set text in form1's label before closing. I have no problem getting...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.