getting data

boomerang boi

Registered User.
Local time
Today, 10:03
Joined
Apr 14, 2008
Messages
16
How can I get data from one form to another form automatically? I am going to get a data from another form. Let's say, the 'another form' has ID NO., SURNAME, FIRST NAME. while the next form to be opened, when the command button is clicked, has ID NO., ADDRESS, and OCCUPATION. How can I automatically get the ID NO. from the 'another form' to the 'next form'? So that I don't need to type it all again. Thanks in advance
 
You could pass the ID NO as a parameter when you open the second form.

Of course if the forms were based on the same query and just displaying different fields then it would all happen automatically.

We really need to know a bit more about your data structure and your database before we can give you the best advice
 
In a macro is Setvalue and code looks like

Forms!FormNametoReceiveData!IDFieldName = Forms!MainForm!IDFieldName

If you do something like that it would normally be when creating a new related record and you would open the other form at New Record. So your code or macro would first open the form at a new record and then do the setvalue. If you need to do more than one field then just add another line to the code or macro.
 
Here's some info about my DB.
TABLE 1: PI this is a abbreviation for personal info.
TABLE 2: FB Family background.

I am trying to do is I have a form for PI then if the user is finished to the form, He/She will click a command button that directs to the form of FB. Both tables have "NUMBER" field (which has nothing to do with them, just created to have relations).

The problem is, If I click the command button, the FB form will show but the NUMBER field is BLANK or is in DEFAULT VALUE.

I am filling up the fields since the query that I have is still empty or I have some data in the query but I want to add more. The NUMBER field is in Text data type.
 
How are your tables linked. Is it a One to one relationship or is it more complex.

If you could post your DB with sample data we may be able to help you better.
 
If you go through the Command Button wizard to open a form and select the 'I want to open the form and find a record' check box the wizard will set up the criteria string for you.
 
How about defining global variables in a module to hold the values you want to transfer? I presume that you would have a button on the first form that opens the second one and, if that's the case, you could set the global variables using VBA code under that button before you open the second form. Having done that you can either retrieve those values in the OnCurrent event of the second form and set the controls to those values or you write functions to retrieve the values in the same module as you declared the variables in and set the default value of the controls on the second form to the values returned by the functions.

For example if you have Module1, FormA and FormB such that FormA has the text box numPersonID and the button buttOpenFormB on it and FormB has the text box numPersID on it you would do the following:

In Module1 define
"Global gblCurrPersID as Integer" and
"Function funCurrPersID() as Integer". (The body of funCurrPersID would consist of the line "funCurrPersID = gblCurrPersID")

In the OnClick event of buttOpenFormB insert the line
"Module1.gblCurrPersID = me.numPersonID" before the code which opens FormB
You can then set the default value of FormB.intPersID to "Module1.funCurrPErsID()" or include the line "me.numPersID = module1.gblCurrPersID" in the OnCurrent event of FormB.

Unless I've gone a bit wrong in the syntax which I've typed off the top of my head that should work. Try creating a small Access application and trying it.
 
Thanks a lot Geoff, that really works.

The only problem is, when I put another record in the second form, the number is the same as in the first record. The two tables are one-to-one relationship, so I want it to change +1 so that it doesn't mess up with my query. Can someone tell me how to do it? Thanks a lot if you help me with this one ^^.
 
I just wanna ask my last question and I hope someone can answer it ^^.

The only problem is, when I put another record in the second form, the number is the same as in the first record. The two tables are one-to-one relationship, so I want it to change +1 so that it doesn't mess up with my query. Can someone tell me how to do it? Thanks a lot if you help me with this one ^^.

sorry if this is a dumb question... I'm just new to VBA and access.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom