Conflicting List Boxes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isaace
    New Member
    • Jan 2012
    • 13

    Conflicting List Boxes

    I have 2 pop up forms which come from a main data entry form. The pop up forms are populated by a list box. When double clicking on the list, that entry is then pulled up on the main form.

    My problem: I've gotten both sets of code to work - BUT NOT AT THE SAME TIME. It seams that they are conflicting for some reason - but now sure why. I think it may even be changing the code once I click on the DoCmd.Close. Not sure if I am going crazy!! Thoughts?? Below is the code...

    Code:
    Private Sub cmdShowActiveLeads_Click()
    
    Dim rs As DAO.Recordset
    Set rs = Forms!frmLeadMain1.RecordsetClone
    'Dim stLeadSearch As String
    'stLeadSearch = "[Lead#']= "
    
    Call rs.FindFirst("[Lead#] =" & Me.Ctl1stLead.Value)
    Forms!frmLeadMain1.Recordset.Bookmark = rs.Bookmark
    Call DoCmd.Close(acForm, "frmFindActiveLead")
    
    
    End Sub
    
    
    Private Sub List4_AfterUpdate()
    
    Me.cmdShowActiveLeads.Enabled = True
    
    End Sub
    
    
    Private Sub List4_DblClick(Cancel As Integer)
    
    If Not IsNull(Me.List4.Value) Then
        Call cmdShowActiveLeads_Click
        
    End If
    
    End Sub
    
    Private Sub Command3_Click()
    On Error GoTo Err_Command3_Click
    
    
        DoCmd.Close
    
    Exit_Command3_Click:
        Exit Sub
    
    Err_Command6_Click:
        MsgBox Err.Description
        Resume Exit_Command3_Click
        
    End Sub
    Code:
    Option Compare Database
    
    Private Sub cmdShowCurrentTenant_Click()
    
    Dim rs As DAO.Recordset
    Set rs = Forms!frmLeadMain1.RecordsetClone
    'Dim stLeadSearch As String
    'stLeadSearch = "[Lead#']= "
    
    Call rs.FindFirst("[Lead#] =" & Me.List4.Value)
    Forms!frmLeadMain1.Recordset.Bookmark = rs.Bookmark
    Call DoCmd.Close(acForm, "frmFindCurrentTenant")
    
    
    End Sub
    
    
    Private Sub List4_AfterUpdate()
    
    Me.cmdShowCurrentTenant.Enabled = True
    
    End Sub
    
    
    Private Sub List4_DblClick(Cancel As Integer)
    
    If Not IsNull(Me.List4.Value) Then
        Call cmdShowCurrentTenant_Click
        
    End If
    
    End Sub
    
    Private Sub Command6_Click()
    On Error GoTo Err_Command6_Click
    
    
        DoCmd.Close
    
    Exit_Command6_Click:
        Exit Sub
    
    Err_Command6_Click:
        MsgBox Err.Description
        Resume Exit_Command6_Click
        
    End Sub
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    What do you mean it's not working at the same time? I see multiple functions and I don't know which ones you mean.

    Comment

    • isaace
      New Member
      • Jan 2012
      • 13

      #3
      for some reason when I click on the cmd close function; it copies the list box control in one of the form's modules to the other other form's module. (i.e it copies and Ctl1stLead to the other module and replaces all 'List4' functions with 'Ctl1stLead' even though that control is not existent in that form.) It only does this for the modules which contain a list box which both originate from the same main form. very weird....

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You're going to have to go into more detail. I have no idea what you mean by a listbox that originates from the same main form. And you mention functions for a control named Ctl1stLead but your code shows no such functions.

        Comment

        • isaace
          New Member
          • Jan 2012
          • 13

          #5
          I have a main form with all leads. I created 2 pop up forms; each contain a list box. the first popup form, has a list box of 'hot leads'. the second pop up form has a list box of all leads which became customers. Upon opening any of the pop up forms, once I double click on a record in the list box (within the form), that record ([Lead#]) is pulled up on the main form. so there are 2 popup forms; each with 1 control; the list box. each list box has a different data source for separate queries. each form has its own vba code for pulling up that lead #(code is above). the problem is once I close one of the forms, it alters the vba code from the other form in that it copies and replaces only the list box control's name within the form vba module. have no idea why this is happening...ver y wierd...I assume it may have something to do with "DAO.Record set" or the rs as I don't understand which either mean; I just copied that section of code from a textbook.

          Does that help a bit??

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            What do you mean it's replacing the VBA code? How do you know it's doing that?

            Comment

            Working...