473,757 Members | 5,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you change the control source of a text box?

31 New Member
I have two forms, one with two command buttons, the other is a testing critera input form. Both cmd bottons open the same form. The first opens it to input test criteria, and is attached to a table. The other cmd button I want to open the same form, but I want it attached to a query to select the test criteria for a specific part which I will use is to test data from another table to pull out the good parts. I'm thinking I need to change the control source for several text boxes to display the proper test criteria from the query. Any ideas on how to do this.
Jan 20 '10 #1
7 4721
Delerna
1,134 Recognized Expert Top Contributor
the general syntax for changing control properties on another form is
Expand|Select|Wrap|Line Numbers
  1. Forms!FormName.ControlName.Property=value
  2.  
Jan 21 '10 #2
thevbist
3 New Member
If I've understood your question correctly, do you want to change the "record source" of a form? Or do you only want to change the "control source" of the text box.
However, I will provide you with both solutions...
To change the "Record Source" of a form.

Here's some code...

Assuming you have a command button on the form called "cmdTestCriteri a".
On the cllick event of "cmdTestCriteri a".


Private Sub cmdTestCriteria _Click()

Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim frmTheSameForm As TheSameForm

Set dbs = CurrentDb()
Set rs = Me.RecordsetClo ne or Me.Recordset

DoCmd.OpenForm "frmTheSameForm "
TheSameForm.Rec ordset = "qryTestCriteri a"
End Sub

If you want to change the "ControlSou rce" of one or several textboxes, then add as many tables and table fields to the query as needed.


Best Regards,

Lamar Dixon, Jr.
President
Sallient Technologies, LLC
MobileMessageMe dia(MCubed)
Jan 21 '10 #3
tomric
31 New Member
Yes, I want to change the record source. I've tried the code and I keep comming up with a compile error, user-defined type not defined, on the statement Dim frmTestingcrite ria as Testingcriteria . The form does exist and that's the name of it, any sugestions as to why this is occuring?
Jan 21 '10 #4
thevbist
3 New Member
Hello,
The statement "Dim frmTestingcrite ria as Testingcriteria " is a euphemism.

The "Compile Error" you are getting is because the form does not exist. Hence the "User-Defined Type". You're not going to open a new form, you're changing the recordset for the EXISTING form.

So here's some code...

Private Sub cmdTestCriteria _Click()

Dim dbs As DAO.Database
Dim rs As DAO.Recordset


Set dbs = CurrentDb()
Set rs = Me.RecordsetClo ne or Me.Recordset

Me.Recordset = "qryTestCriteri a"
End Sub
Jan 22 '10 #5
tomric
31 New Member
Will that allow to open a second form and change the record set of that form at the same time?
Jan 22 '10 #6
TheSmileyCoder
2,322 Recognized Expert Moderator Top Contributor
This code will change the subform's source object (form) and then alter the recordsource.

I have used this code along with a treeview where a user can click on several nodes, representing different things. Based on what tag the node has, different forms will be opened.

The frm_Container is the name of the control holding the subform. This is just example code and you will have to modify it of course.


Expand|Select|Wrap|Line Numbers
  1. Select Case strTag
  2.                 Case "System"
  3.                     'Open the system Documents form
  4.                     If Not Me.frm_Container.SourceObject = "frm_System" Then Me.frm_Container.SourceObject = "frm_System"
  5.                     If Not Me.lbl_FormContainer.Caption = "System" Then Me.lbl_FormContainer.Caption = "System"
  6.                     'Set recordsource
  7.                     Me.frm_Container.Form.RecordSource = "SELECT tbl_EvalNodes.* " & _
  8.                                                     " FROM tbl_EvalNodes " & _
  9.                                                     " WHERE KEY_EvalNode=" & getKeyItem(node.Key)
  10. End Select
To change a single textbox to use another controlsource (I have not tested the implications of this or if it is possible at runtime)
Expand|Select|Wrap|Line Numbers
  1. me.tb_BidderID.ControlSource="[tx_Bidder]"
I think you will need to try it out, to see what happens when changing this at runtime. For instance, if user has allready entered a value in textbox, and you change the controlsource, what then?
Jan 22 '10 #7
tomric
31 New Member
Thank you very much, I got it to work.
Jan 26 '10 #8

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

Similar topics

3
2036
by: Billy Jacobs | last post by:
I have created a DataGridColumnDatePicker Component so that I can put a datetimepicker control in my datagrid. It almost works. When I put my mouse in the cell it changes to a datetimepicker control. I can then select a date which displays in the cell. When I leave the cell however I get the following error:
13
4180
by: nyt | last post by:
I have a problem of number and text field. I got the database file(mdb) that contains many combo boxes used and its list values are created by "value list" For eg field Field name= 'furniture' , data type='Number' ,Display Control='Combo Box', RowSource Type = 'Value List' and Row Source = ' 0;"chair";1;"Table";2;"Bed" ' Therefore, in data sheet view of table, if we select (1 : Table ) ,
1
2353
by: Mirek Endys | last post by:
Hi all, I thought, that this is an usual thing, but Im wrong. I have a DataList control and there is a Label control. I need to change the Text propertz of the Label control. How to do it. Here is my function I want to use, but it is not working. I can Find Label in DataListItem, but the change is not dispalyed.
0
2092
by: nate | last post by:
the error returned is this: Server Error in '/AnnAccRpt' Application. -------------------------------------------------------------------------------- Could not find control 'DropDownList1' in ControlParameter 'DropDownList1'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
2
7988
by: Greg Strong | last post by:
Hello All, Is it possible to change table field lookup properties in code? I've been able to change other field properties in code, however so far no luck with field lookup properties. What I've done for test purposes is use a text input file for the table field lookup properties. I thought that I'd start first by just changing the 'Display Control' property. Thanks to Allen Browne for some ideals per...
14
14657
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
8
3273
by: mlwerth | last post by:
Dear Access Group: This is the most basic and most embarrassing of questions, but I cannot find where to change the data type of a text field that I have in Access 2003 to a number field. I've searched high and low through help databases and on the internet. The directions say to : Open the table in Design view Click the Data Type column of the field you want to change, click the
5
1984
by: agarwasa2008 | last post by:
Hi, I have a linked table called tbltest and some bounded forms (which add, update, delete records) that were created using that linked table. For some necessary reasons I had to create another linked table called tblComponents and then I bounded the original forms to this new table. I did change the control source: Description (Field name) RowSource Type: Table/Query (which remains the same)
15
40675
beacon
by: beacon | last post by:
Hi everybody, Using Access 2003. I'm trying to dynamically set the record source for the current form and set the control source for a text box to input data to one of three tables. I have a form (frmAddNewUser) that will add users to one of three separate tables (tblDefsAFP, tblDefsMSU, tblDefsWF) based on the selection of an option button from an option group on the same form. I have a textbox (txtNewUser) that accepts the name of...
6
4437
by: AAaron123 | last post by:
I'm using the CreateUserWizard Web Server Control The error message when the passwords do not match is colored red. Red does not show well against my background so I like to change that color. I only find 3 color settings: BackColor, BorderColor, and ForeColor. I the first two are evidently not what I need. I tried forecolor and it simply changed all the text but not the error message (as you would expect, but I tried anyway).
0
9297
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
10069
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9904
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
9884
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
9735
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...
0
8736
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
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
6556
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();...
3
2697
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.