Rach877
Apr 6th, 2000, 03:07 AM
I am having a problem with a project that I am working on for my Visual Basic 2 class, and my teacher doesn't seem to be able to help me. We are supposed to create an MDI project. When the project starts up just the MDI Parent for m loads. The user then has to click on File then Open Customer. When this happens, an input box comes up for the user to enter a customer number into. After they enter the number the program goes out, creates an instance of the form, pulls the necessary records from a database table and assigns them to the appropriate text boxes on the Child form, then shows the child form. The problem is, is that if the user opens up another customer window, say customer #2,and the first time they opened up customer #1, the correct records load. But if the user switches back to the #1 form, because it is still open, and moves to the next record, the #2 records show up. I asked my teacher, and he said that I should get the parent form to pull the information and assign the recordset to the child form, but I have no idea how to do this. We are not supposed to use the Data control either. Here is what my code looks like:
Public Sub OpenCustomerRecords()
Dim intCounter As Integer
intCustomerNumber = InputBox("Enter customer number")
Set gdbMentor = _
OpenDatabase("C:\1076-5\Chapter.11\Exercise\Mentor.mdb")
If intCounter < 1 Then
intCounter = 1
ReDim gchildEx3Array(intCounter)
gchildEx3Array(intCounter).Tag = intCounter
gchildEx3Array(intCounter).Caption = _
"Mentor Customer Tracking - Customer Number " & intCustomerNumber gchildEx3Array(intCounter).Show
Else
intCounter = UBound(gchildEx3Array)
ReDim gchildEx3Array(intCounter)
gchildEx3Array(intCounter).Tag = intCounter
gchildEx3Array(intCounter).Caption = _
"Mentor Customer Tracking - Customer Number " & CustomerNumber
gchildEx3Array(intCounter).Show
End If
End Sub
The following is the code in the child form:
Private Sub Form_Load() Dim pstrFROM As String
Dim pstrWHERE As String
Dim psqlSELECT As String
pstrFROM = " FROM tblCustomer"
pstrWHERE = " WHERE fldCustomerID = " & "'" & intCustomerNumber & "'"
psqlSELECT = "SELECT *" & pstrFROM & pstrWHERE
Set gdbMentorRecords = _
Module1.gdbMentor.OpenRecordset(psqlSELECT)
Call LoadCurrentRecords
End Sub
Public Sub LoadCurrentRecords()
On Error GoTo LoadCurrentRecords_error:
txtCustomerID = gdbMentorRecor txtPerson = gdbMentorRecords![fldPersonName] txtAddress = gdbMentorRecords![fldAddress]
txtCity = gdbMentorRecords![fldCity]
txtState = gdbMentorRecords![fldState]
txtZip = gdbMentorRecords![fldZipcode]
Exit Sub
LoadCurrentRecords_error:
End Sub
Any help would be great!
Public Sub OpenCustomerRecords()
Dim intCounter As Integer
intCustomerNumber = InputBox("Enter customer number")
Set gdbMentor = _
OpenDatabase("C:\1076-5\Chapter.11\Exercise\Mentor.mdb")
If intCounter < 1 Then
intCounter = 1
ReDim gchildEx3Array(intCounter)
gchildEx3Array(intCounter).Tag = intCounter
gchildEx3Array(intCounter).Caption = _
"Mentor Customer Tracking - Customer Number " & intCustomerNumber gchildEx3Array(intCounter).Show
Else
intCounter = UBound(gchildEx3Array)
ReDim gchildEx3Array(intCounter)
gchildEx3Array(intCounter).Tag = intCounter
gchildEx3Array(intCounter).Caption = _
"Mentor Customer Tracking - Customer Number " & CustomerNumber
gchildEx3Array(intCounter).Show
End If
End Sub
The following is the code in the child form:
Private Sub Form_Load() Dim pstrFROM As String
Dim pstrWHERE As String
Dim psqlSELECT As String
pstrFROM = " FROM tblCustomer"
pstrWHERE = " WHERE fldCustomerID = " & "'" & intCustomerNumber & "'"
psqlSELECT = "SELECT *" & pstrFROM & pstrWHERE
Set gdbMentorRecords = _
Module1.gdbMentor.OpenRecordset(psqlSELECT)
Call LoadCurrentRecords
End Sub
Public Sub LoadCurrentRecords()
On Error GoTo LoadCurrentRecords_error:
txtCustomerID = gdbMentorRecor txtPerson = gdbMentorRecords![fldPersonName] txtAddress = gdbMentorRecords![fldAddress]
txtCity = gdbMentorRecords![fldCity]
txtState = gdbMentorRecords![fldState]
txtZip = gdbMentorRecords![fldZipcode]
Exit Sub
LoadCurrentRecords_error:
End Sub
Any help would be great!