Multi Form Program

renegade

Newcomer
Joined
Feb 14, 2003
Messages
12
I'm creating a Multi form program that save all input information to a Ramdom Access file. I need to save all information on all forms from each form. I made the main form save all information on 3 forms but I can't get form2 and form3 to save all information on all 3 forms. The save button on Form2 and Form3 only will save informtion on their respective form. How do I make form2 and form3 save all informtion on all 3 forms? My forms are declared Public, I have tried Me.DialagResult = DialogResult.Yes, nothing seams to work. Any ideas? Help!!
 
Last edited:
I'd have to see some of your code to know how you're saving things from Form1. Only then can I suggest something for Forms 2 and 3.

-Nerseus
 
Module 1
Structure Members
<VBFixedString(15)> Dim Fname1, Lname1, EmpNum1, RecNum1, DoB, Age, Phone, City, State, Zip, Ssn, Hire, Service, Jt, Hr, Shift, Facility, HealthIns, DentalIns, LifeIns, Retirement As String
<VBFixedString(20)> Dim Address As String
End Structure
Public Record(30) As Members
Public f1 As New Form1()
Public f2 As New Form2()
Public f3 As New Form3()
Form 1 'Save all input data from all forms
Dim Record As Members
Record.Fname1 = txtFname1.Text
Record.Fname1 = f2.txtFname2.Text
Record.Fname1 = f3.txtFname3.Text
Record.Lname1 = txtLname1.Text
Record.Lname1 = f2.txtLname2.Text
Record.Lname1 = f3.txtLname3.Text
Record.DoB = txtDoB.Text
Record.Age = txtAge.Text
Record.Phone = txtPhone.Text
Record.Address = txtAddress.Text
Record.City = txtCity.Text
Record.State = txtState.Text
Record.Zip = txtZip.Text
Record.EmpNum1 = txtEmpNum1.Text
Record.EmpNum1 = f2.txtEmpNum2.Text
Record.EmpNum1 = f3.txtEmpNum3.Text
Record.Ssn = txtSsn.Text
Record.Hire = txtHire.Text
Record.Service = txtService.Text
Record.RecNum1 = txtRecNum1.Text
Record.Jt = f2.txtJt.Text
Record.Hr = f2.txtHr.Text
Record.Shift = f2.txtShift.Text
Record.Facility = f2.txtFacility.Text
Record.HealthIns = f3.cbHealthIns.Text
Record.DentalIns = f3.cbDentalIns.Text
Record.LifeIns = f3.cbLifeIns.Text
Record.Retirement = f3.cb401K.Text

Form 2 'Save all input data after editting (doesn't work)

Dim Record As Members
Record.Jt = txtJt.Text
Record.Shift = txtShift.Text
Record.Hr = txtHr.Text
Record.Facility = txtFacility.Text
f1.txtFname1.Text = Record.Fname1
Record.Lname1 = f1.txtLname1.Text
Record.EmpNum1 = f1.txtEmpNum1.Text
Record.RecNum1 = f1.txtRecNum1.Text
Record.DoB = f1.txtDoB.Text
Record.Age = f1.txtAge.Text
Record.Phone = f1.txtPhone.Text
Record.Address = f1.txtAddress.Text
Record.City = f1.txtCity.Text
Record.State = f1.txtState.Text
Record.Zip = f1.txtZip.Text
Record.Ssn = f1.txtSsn.Text
Record.Hire = f1.txtHire.Text
Record.Service = f1.txtService.Text
Record.HealthIns = f3.cbHealthIns.Text
Record.DentalIns = f3.cbDentalIns.Text
Record.LifeIns = f3.cbLifeIns.Text
Record.Retirement = f3.cb401K.Text

When saved from Form 2 it save form 2 and Form3 information but not form1, all form 1 data fields are empty. Thanks
Renegade
 
Multi form issues

I have it declared as a Structure isn't that different than an array?
If I remove it locally it says that it's not a member of my "system array"
Is my Global Declaration incorrect? Because I have to declare it locally to not have an error?
 
Your global definition is:
Public Record(30) As Members

your local definition is:
Dim Record As Members

Your code is using:
Record.Jt = txtJt.Text

which means it's using the local Record variable, not the global one. If you delete the local variable, you'd have to change your code to:
Record(0).Jt = txtJt.Text

Or use whatever index you want instead of 0 (zero). The code you posted only shows how you're filling the structure. I'm not sure how you're doing the saving, so it's impossible to say why one form would save and another would not.

-Nerseus
 
Multi form issues

So if I change my Global declaration to Record(1) As Members and change all my records locally by Record(1).txtJt.Text then that would be correct? I'll do it right now and get back to you. Thanks!
Renegade
 
Well, I'm not sure why you have a global array. Maybe you want your global version of the Record variable to NOT be an array? Only YOU can answer that :)

If you do change the global reference to NOT be an array, I'd delete all your local instances since I'm pretty sure that's not what you want.

-Ner
 
Multi form issues

I changed all references locally to my global declaration of Record(30) and took out all local declarations and now everything saves just fine. Thanks for pointing out my error on my declarations that was my down fall.
Thanks again!
renegade
 
I'm Still having trouble saving data from Form2 and Form3 , it just saves Form 2 and 3 data but not Form1 data, all form1 fields are blank when I recall the saved record. Help!
 
Can you post the whole project as a zip file? It would be a lot easier to see the problem that way. Make sure you only zip the root folder, don't include the bin folder (no executables in the zip, please).

-Nerseus
 
There is an .exe file in the object/debug folder also. By root file you mean the whole file except the .exe files?
Renegade
 
Back
Top