Results 1 to 4 of 4

Thread: Recordset

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    16
    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 for 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 " & intCustomerNumber
    gchildEx3Array(intCounter).Show
    End If


    End Sub

    The following is the code in the child form:

    Private Sub cmdMovePrevious_Click()

    On Error GoTo MovePrevious_Error
    gdbMentorRecords.MovePrevious
    Call LoadCurrentRecords

    Exit Sub

    MovePrevious_Error:
    pstrMessage = "First record displayed."
    MsgBox pstrMessage, vbExclamation, "Mentor Customer Tracking - Error"
    End Sub

    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 = gdbMentorRecords![fldCustomerID]
    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!

  2. #2
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    You can easily put an Unload statment in so that when you switch to the second form the first one closes. Then when you switch to the first one you would need to run a Show statement to reload #2.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    16

    Not quite right

    That would be easy, except the user has to be able to go back and forth between the two child forms without closing them. The child forms are losing their recordsets everytime a new for is opened. That's the problem

  4. #4
    Addicted Member
    Join Date
    Sep 1999
    Posts
    154
    Well, if you cant use a Data Control then maybe you could do something like use the zOrder function or try Hide or possibly minimize the form and then maximize it when you need it?????

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width