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.
7 4721 Delerna 1,134
Recognized Expert Top Contributor
the general syntax for changing control properties on another form is -
Forms!FormName.ControlName.Property=value
-
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)
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?
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
Will that allow to open a second form and change the record set of that form at the same time?
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. - Select Case strTag
-
Case "System"
-
'Open the system Documents form
-
If Not Me.frm_Container.SourceObject = "frm_System" Then Me.frm_Container.SourceObject = "frm_System"
-
If Not Me.lbl_FormContainer.Caption = "System" Then Me.lbl_FormContainer.Caption = "System"
-
'Set recordsource
-
Me.frm_Container.Form.RecordSource = "SELECT tbl_EvalNodes.* " & _
-
" FROM tbl_EvalNodes " & _
-
" WHERE KEY_EvalNode=" & getKeyItem(node.Key)
-
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) - 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?
Thank you very much, I got it to work.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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:
|
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 ) ,
|
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.
|
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.
|
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...
| |
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
|
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
|
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)
|
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...
|
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).
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |
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();...
|
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...
| |