Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Pass variables from form to form

Status
Not open for further replies.

goobil

Technical User
Aug 9, 2003
38
AG
Hi all,
The company I’m working for have a three pages form that customers will complete, I want to build an application in VB6 using access2000 as the database so we can start storing the information on a database for easy access.
My question is and I will try and make it as clear as I can.
Question (1)
Since the form for the customers is three pages long meant that my form in VB will be very long as well.
I was thinking about using three forms in VB and used a command button at the bottom of the forms that say next page and on the last page I will have the save button.
The problem is how can I store the information in memory so when I click save it’s will save all the information from the three forms?
I know in ASP page I used session to store variables but I don’t know what to use in VB6.

Question (2)
Can I use MultiPage on a regular form? And will that work?
Is there another way of doing this?

Thanks in Advance
Kenneth
 
You could (in a module) delcare publically variables that are assgined to the (1st/2nd/3rd) form. Then when the "next" button is clicked for the form #1, you could then just do something like this:

set storeFrm1 = me

then you could just refer to storeFrm1 for all of form 1's properties etc.

If it does not keep it's value when u try to refer to it later, you could try (at the loading of the main form - the first one that loads with program) doing this *then of course do what I mentioned before*:

set storeFrm1 = new CustomerFormOne


-----------------------
hope this helps.
 
Hi OCODE, or anyone
I am trying to understand what you are saying but I am not that of an expert in VB.
I have created three forms.
Each forms have one text box “ text1,textt2,text3”
The first two forms have two command buttons.
Private Sub Command1_Click()
Form2.Show
End Sub
******************************
Form2 button
Private Sub Command1_Click()
Form2.Show
End Sub
And form three will have the save button that will save the information
Can you please have an example on how to store the variables in the module?
Can this work from the module?

Option Explicit
Dim xtext1 As String
xtext = Text1.Text

 
FYI: There is a FAQ on this.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
If you haven't found the FAQ helpful to your needs just tell me and I will provide an example.
 
Am I missing something here? Text boxes on loaded forms are readable from anywhere, yes? eg.: form1.text1.text
 
..but not from a different form, and not if they were declared as being private.

There's all kinds of gotchas in this stuff, that vary depending on how the application is structured.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
I often read properties and invoke methods from a form other than the one with the focus.
 
That is true ghardenb.
I have come up with a few tricks of my own.
i can call the string from form one form1.txttext1.text. in form2.
So i have created a auto number from the database and used that for the form label.
When the cmdnext_Click(Index As Integer) is load it go to the database get the last number from the database and add one to it so my form label will be form12 then i insert the content of form1 in a temp database and recall it from form2

xform1 = form1.txttext1.text

select * from tempdata where formID = xform1

Any Suggestion or is there a shorter way?
 
hi goobil,

i think it will be easier if you use sstab control which means you can place the textboxes on each tab instead of 3 forms. Now you can save all at a time. No need of temp database. I hope it may help u .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top