473,387 Members | 1,504 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,387 software developers and data experts.

Transfering data from text box on one form to another form using vb

1
Hi Everyone,

I have a little bit of problem with my database. I have a textbox ( the name of the textbox is location) on one form and 1 command button. I also made another form with 1 textbox (the name of the textbox is designator) . I want to use vb on programming the command button. All I want to happen is that after I place some text on the texbox (location) I click the command button and the text on (location) will be copied to the other textbox(designator) which is located on the other form. I already tried declaring a global variable and save the data on this variable but I couldnt use the variable on other form even thought I set it as public. I would appreciate any help. Thanks in advance.
Mar 12 '08 #1
2 7831
rdsandy
20
Hi Hitman,

Im not sure how you set up your global variable and how you used it, but i'll suggest how I do it. Make a new Module (by going on the Module section of the database window and clicking new). Then type in:

Expand|Select|Wrap|Line Numbers
  1. Global yourVariableName As yourDataType
  2.  
where yourVariableName is the name of the variable, and yourVariableType is the data type for it (ie: for text use String etc). Then on the AfterUpdate of your text box put:

Expand|Select|Wrap|Line Numbers
  1. yourVariableName = Me.Location
  2.  
Now, from here if you are only setting whatever is in location to be in designator (i think it was called) just once (ie, set it when you open the form), then all you have to do is set the text box to the global variable on form open, like:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Open(Cancel As Integer)
  2.  
  3. Me.Designator = yourVariableName
  4.  
  5. End Sub
  6.  
and thats it, you don't really need the command button if its only used to set designator to whatever locations is.

Hope this helps,

Andrew
Mar 12 '08 #2
rdsandy
20
After re-reading your post, it sounds like you have both forms open at the same time. I just made a dummy database, made two forms, one called Location, with a text box called Location, and a command button called cmbCopy, and another form called Designator with a text box called Designator. I made a new module and the code in there looks like this:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Global copyText As String
  4.  
On the Location form I have this code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2.  
  3. Private Sub cmbCopy_Click()
  4.  
  5.     copyText = Me.Location
  6.  
  7.     Forms!designator!designator = copyText
  8.  
  9. End Sub
  10.  
When I type something in Location text box and click the button, it appears in the Designator text box, so it should work for you.

Hope this helps,

Andrew
Mar 12 '08 #3

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
32
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being...
2
by: Niyazi | last post by:
Hi, I have BIG question and I gues it is the BEST question. I have a problem that I am guessing the best solution is to create some sort ..NET Services. This Service(s) must check every...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
2
by: Piotr Karwatka | last post by:
Hi! I have a little problem an qeustion. In .NET Windows Forms I can do something like that: - i have forms - Form1 Form2, on first form i have TextBox1 control on 2nd form I have Button1...
2
by: Ben | last post by:
I used the following code to transfer some web control data from Page1.aspx to Page2.aspx. It is successful to get the TextBox.Text over, but the DropDownList data failed to appear in Page2. I...
3
by: Chris S | last post by:
I'm relatively new to VB.NET and have what's probably a very simple question. I'm trying to get one form to access (view and modify) data on another form. For example, the startup object is a...
7
by: ckpoll2 | last post by:
Hello, I'm creating a form that will always show information for the last 7 days by using date() and date()-1 and so forth. What I need to do is have a value that has been calculated in a text...
13
by: hexagram | last post by:
hi guys can anybody can teach me how to do this scenario Transfering Data of a form to a new form The Scenario is: I have a Delivery Receipt Form (Hardware) with a fields of the following ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.