473,418 Members | 2,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 473,418 software developers and data experts.

from textbox to textbox on ANOTHER form

135 100+
Hello

I have two forms: Projects and Engineering
In PROJECTS i have a textbox (VARIANT1) where the user will enter some text. I want this text to automatically appear as text on another TEXTBOX (VARIANT1LABEL) on the second form (ENGINEERING).

How can i do this???
Sep 4 '07 #1
11 6183
Rabbit
12,516 Expert Mod 8TB
Forms!FormName!ControlName
Sep 4 '07 #2
Gilberto
135 100+
Forms!FormName!ControlName
This worked perfectly, thank you.

My only issue now is that the first form (PROJECTS) need to be running so that i dont get the ERROR '2450' CANT FIND THE FORM (PROJECTS) when i open the second form (ENGINEERING).

Is there a way that instead of displaying the value from the textbox from the form (PROJECTS) that it displays the value on the PROJECTS TABLE?? which is already stored and doesnt need to be OPEN so that the whole thing works?

ive tried:

Private Sub Form_open(Cancel As Integer)
Forms!Engineering!Variant1 = Tables!Projects!Variant1
End Sub

but it doesnt work (error 424, object required).

I also found out that the textbox on the second form (ENGINEERING) has to be UNBOUND so that this works. I NEED to BOUND this textbox so that the input displayed gets stored on this forms table (ENGINEERING TABLE), is there any way to accomplish this?


Thanks again,
Gilberto
Sep 5 '07 #3
Stwange
126 Expert 100+
-----------------------------------------------
Sep 5 '07 #4
Stwange
126 Expert 100+
Gilberto:
try this code, if I have understood you correctly it should do what you need:
Expand|Select|Wrap|Line Numbers
  1. Dim rs as DAO.recordSet
  2. Set rs = DBEngine(0)(0).openRecordSet("SELECT Variant1 FROM Projects WHERE primary_key = '" & txtkey.value & "';")
  3. 'replace Variant1 with your field name, Projects with your table name, and txtkey.value with wherever your primary key is stored.
  4. 'Also, if your primary key is stored as a number in the table, change the WHERE clause to WHERE primary_key = " & txtkey.value & ";")
  5. 'you can now refer to the field as such:
  6. dim var1 as String: var1 = rs!Variant1
  7. 'now, if the Engineering form is open, updating the text field should work whether it is bound or not, and so update the table. If it doesn't, you can leave it unbound and work around this:
  8. var1 = Forms!Engineering!Variant1 'to store the old value as a parameter (for updating) - only needed if the field has to stay unbound.
  9. Forms!Engineering!Variant1 = rs!Variant1 'this should be the only line you need.
  10. DoCmd.runSQL("UPDATE tableName SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';") 'Updates the table (use if the text box is unbound)
  11. 'if Variant1 is stored as a number in the tables, again replace the WHERE with WHERE Variant1 = " & var1 & ";") 
  12.  
Hope this helps.
Sep 5 '07 #5
Gilberto
135 100+
Gilberto:
try this code, if I have understood you correctly it should do what you need:
Expand|Select|Wrap|Line Numbers
  1. Dim rs as DAO.recordSet
  2. Set rs = DBEngine(0)(0).openRecordSet("SELECT Variant1 FROM Projects WHERE primary_key = '" & txtkey.value & "';")
  3. 'replace Variant1 with your field name, Projects with your table name, and txtkey.value with wherever your primary key is stored.
  4. 'Also, if your primary key is stored as a number in the table, change the WHERE clause to WHERE primary_key = " & txtkey.value & ";")
  5. 'you can now refer to the field as such:
  6. dim var1 as String: var1 = rs!Variant1
  7. 'now, if the Engineering form is open, updating the text field should work whether it is bound or not, and so update the table. If it doesn't, you can leave it unbound and work around this:
  8. var1 = Forms!Engineering!Variant1 'to store the old value as a parameter (for updating) - only needed if the field has to stay unbound.
  9. Forms!Engineering!Variant1 = rs!Variant1 'this should be the only line you need.
  10. DoCmd.runSQL("UPDATE tableName SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';") 'Updates the table (use if the text box is unbound)
  11. 'if Variant1 is stored as a number in the tables, again replace the WHERE with WHERE Variant1 = " & var1 & ";") 
  12.  
Hope this helps.
Thanks for the fast reply. Im using:

1 Private Sub Form_open(Cancel As Integer)
2 Forms!Engineering!ProjectName = Forms!Projects!ProjectName

3 Dim rs As DAO.Recordset
4 Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE primary_key = " & EngineeringID.Value & ";")
5 Dim var1 As String: var1 = rs!Variant1
6 Forms!Engineering!Variant1 = rs!Variant1
7 DoCmd.RunSQL ("UPDATE tableName SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")

End Sub


but the error 3061 TOO FEW PARAMETERS. EXPECTED 1 pups up and the line number 4 its underlined.

How can i fix this?
Sep 5 '07 #6
Stwange
126 Expert 100+
Thanks for the fast reply. Im using:

1 Private Sub Form_open(Cancel As Integer)
2 Forms!Engineering!ProjectName = Forms!Projects!ProjectName

3 Dim rs As DAO.Recordset
4 Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE primary_key = " & EngineeringID.Value & ";")
5 Dim var1 As String: var1 = rs!Variant1
6 Forms!Engineering!Variant1 = rs!Variant1
7 DoCmd.RunSQL ("UPDATE tableName SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")

End Sub


but the error 3061 TOO FEW PARAMETERS. EXPECTED 1 pups up and the line number 4 its underlined.

How can i fix this?
Sorry, I should have made this explicitly obvious: Replace primary_key with the field name of the primary key in your table, so at a guess:
Expand|Select|Wrap|Line Numbers
  1. Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
Sep 5 '07 #7
Gilberto
135 100+
Sorry, I should have made this explicitly obvious: Replace primary_key with the field name of the primary key in your table, so at a guess:
Expand|Select|Wrap|Line Numbers
  1. Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
hehehe i should have guessed that...thanks BUT still not working :(

Im using:

Private Sub Form_open(Cancel As Integer)

Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
Dim var1 As String: var1 = rs!Variant1
Forms!Engineering!Variant1 = rs!Variant1
DoCmd.RunSQL ("UPDATE tableName SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")

End Sub

and still gettng the "ERROR 3061 Too few parameters. Expected 1"

any idea??

thanks again
Sep 6 '07 #8
Stwange
126 Expert 100+
Only a slight change, but try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_open(Cancel As Integer)
  2.  
  3. Dim rs As DAO.Recordset
  4. Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
  5. If Not rs.EOF Then
  6.     Dim var1 As String: var1 = rs!Variant1
  7.     Forms!Engineering!Variant1 = rs!Variant1
  8.     DoCmd.RunSQL ("UPDATE Projects SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")
  9. End If
  10. End Sub
  11.  
MAKE SURE: Variant1 is actually a field in this table. If you still get an error, tell me what error and which line.

Hope this helps.
Sep 6 '07 #9
Gilberto
135 100+
Only a slight change, but try this:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_open(Cancel As Integer)
  2.  
  3. Dim rs As DAO.Recordset
  4. Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
  5. If Not rs.EOF Then
  6.     Dim var1 As String: var1 = rs!Variant1
  7.     Forms!Engineering!Variant1 = rs!Variant1
  8.     DoCmd.RunSQL ("UPDATE Projects SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")
  9. End If
  10. End Sub
  11.  
MAKE SURE: Variant1 is actually a field in this table. If you still get an error, tell me what error and which line.

Hope this helps.

Hello again,

Its still not working :(

Just to confirm:

which primary key should i enter in the code? the one from the table where the user inputs the text or the one from the table where the text its going to be displayed???
im entering this code into the ENGINEERING form which is where the textbox is supposed to DISPLAY the text entered on form PROJECTS
names of BOTH textboxes are VARIANT1 both bounded to VARIANT1 field on their corresponding table.

I tried both ways and the errors are the following:

OPTION 1

1 Private Sub Form_open(Cancel As Integer)
2 Dim rs As DAO.Recordset
3 Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
4 If Not rs.EOF Then
5 Dim var1 As String: var1 = rs!Variant1
6 Forms!Engineering!Variant1 = rs!Variant1
7 DoCmd.RunSQL ("UPDATE Projects SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")
8 End If
9 End Sub

With ENGINEERINGID (where the text should be displayed) the error is: '3061' "too few parameters. Expected 1" with line #3 highlighted


OPTION 2

1 Private Sub Form_open(Cancel As Integer)
2 Dim rs As DAO.Recordset
3 Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE ProjectID = " & ProjectID.Value & ";")
4 If Not rs.EOF Then
5 Dim var1 As String: var1 = rs!Variant1
6 Forms!Engineering!Variant1 = rs!Variant1
7 DoCmd.RunSQL ("UPDATE Projects SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")
8 End If
9 End Sub

with PROJECTID (table where the user enters the text) the error is: '424' "object required" with the same line (#3) highlighted

thanks again
Sep 6 '07 #10
Stwange
126 Expert 100+
Hello again,

Its still not working :(

Just to confirm:

which primary key should i enter in the code? the one from the table where the user inputs the text or the one from the table where the text its going to be displayed???
im entering this code into the ENGINEERING form which is where the textbox is supposed to DISPLAY the text entered on form PROJECTS
names of BOTH textboxes are VARIANT1 both bounded to VARIANT1 field on their corresponding table.

I tried both ways and the errors are the following:

OPTION 1

1 Private Sub Form_open(Cancel As Integer)
2 Dim rs As DAO.Recordset
3 Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE EngineeringID = " & EngineeringID.Value & ";")
4 If Not rs.EOF Then
5 Dim var1 As String: var1 = rs!Variant1
6 Forms!Engineering!Variant1 = rs!Variant1
7 DoCmd.RunSQL ("UPDATE Projects SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")
8 End If
9 End Sub

With ENGINEERINGID (where the text should be displayed) the error is: '3061' "too few parameters. Expected 1" with line #3 highlighted


OPTION 2

1 Private Sub Form_open(Cancel As Integer)
2 Dim rs As DAO.Recordset
3 Set rs = DBEngine(0)(0).OpenRecordset("SELECT Variant1 FROM Projects WHERE ProjectID = " & ProjectID.Value & ";")
4 If Not rs.EOF Then
5 Dim var1 As String: var1 = rs!Variant1
6 Forms!Engineering!Variant1 = rs!Variant1
7 DoCmd.RunSQL ("UPDATE Projects SET Variant1 = '" & rs!Variant1 & "' WHERE Variant1 = '" & var1 & "';")
8 End If
9 End Sub

with PROJECTID (table where the user enters the text) the error is: '424' "object required" with the same line (#3) highlighted

thanks again
I think I know what's causing these errors, but I'm having a bit of trouble understanding your logic to help you fix them. It doesn't necessarily have to be a primary key you check, just whatever you are using to identify which fields need updating.
Ie. if you want ALL the Variant1s updating, you don't need the WHERE clause, if you want the Variant1 updating on Projects, you need the Projects primary key there (which I presumed was currently displayed in the bound text box, hence the code).

An explanation of your errors:
Option 1. I'm guessing there is no EngineeringID on the table Projects. Replace the EngineeringID with ProjectID.

Option 2. It doesn't seem to be finding ProjectID (from the ProjectID.value), does this control exist? If so, is it on a different form? If it is you need to refer to it as [Forms]![insertFormNameHere]![ProjectID].value

Try those, and have a think about what you are trying to update. If I can get a clearer picture I might be able to help you more.
Sep 6 '07 #11
Gilberto
135 100+
I think I know what's causing these errors, but I'm having a bit of trouble understanding your logic to help you fix them. It doesn't necessarily have to be a primary key you check, just whatever you are using to identify which fields need updating.
Ie. if you want ALL the Variant1s updating, you don't need the WHERE clause, if you want the Variant1 updating on Projects, you need the Projects primary key there (which I presumed was currently displayed in the bound text box, hence the code).

An explanation of your errors:
Option 1. I'm guessing there is no EngineeringID on the table Projects. Replace the EngineeringID with ProjectID.

Option 2. It doesn't seem to be finding ProjectID (from the ProjectID.value), does this control exist? If so, is it on a different form? If it is you need to refer to it as [Forms]![insertFormNameHere]![ProjectID].value

Try those, and have a think about what you are trying to update. If I can get a clearer picture I might be able to help you more.
That worked perfectly. I just took out the WERE clause and it WORKED!!! Now i can read on the second form a text which the user entered on the first form.
My only problem now is that this text displayed on the second form doesnt get stored anywhere on thats form table. This is not a problem as i dont require this however now i have a similar issue with another textbox.

On the first form (PROJECTS) i have a textbox (PROJECTNAME) which the user enters when opening the database.

On a second form (ENGINEERING) i have a list of products (PRODUCT NAME FRENCH) with some fields describing each product along with a field named PROJECTNAME which will "classify" evey product under a specific project.

I need the text (the name of the project) entered by the user on the PROJECT form (on the PROJECTNAME textbox) to be stored automatically as a record on every PRODUCT (under the field PROJECTNAME on the ENGINEERING table).

So that i can design a query that will give the user every product wich belongs to THAT project name he first specified.

Can this be done? Could you help me with some code?

I WILL CONTINUE THIS NEW THREAD WILL CONTINUE UNDER THE TITTLE "automatically store as a record the value of a textbox of another form"
Sep 6 '07 #12

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

Similar topics

5
by: Taryon | last post by:
Consider the Form A calling the Form B. In the Form B i need to access the values of the Form A textbox. Normally i create the textbox as public. BUT in this case, the textbox of Form A will be...
28
by: kfrost | last post by:
I know this is probably simple but I have a C# form and the class for the form is called sbaSynch. I have a textbox name txtServerName. I'm creating a class to manipulate XML functions so I...
2
by: Marcelo | last post by:
Hi guys, I'm using the following code to send values from one page to another, but seems to me, that the event Page_Load in the receiving page never fires. Why? This is the code: Thanks ...
3
by: michael_vanommeren | last post by:
I have two web applications that I am working with and I am trying to do a Response.Redirect from one to the other. They are setup as separate web applications on the same IIS server. If I go...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
2
by: panwala_bhavesh | last post by:
Thanks in advance... I have a form displaying the results of a query in a continuous form style. I want to be able to double-click on the key field of the form (a textbox, in this case a AssetID)...
0
by: CCLeasing | last post by:
Hello, I have searched google but can not find a straight forward answer to my problem. Hopefuly someone will be kind enough to offer their expertise. Please forgive if this seems a bit convoluted...
4
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have a strange yet very simple problem with the asp.net Textbox web control. On an empty asp.net page, add a single asp:TextBox control with Autopostback=false with nothing else on...
16
by: Mike | last post by:
Hi, I have a form with some controls, and a different class that needs to modify some control properties at run time. Hoy can I reference the from so I have access to its controls and...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
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...
0
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...

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.