i wondered if anyone could help me with this.

i have a button on a form (frmUpdateProduct). this button opens up another form (frmSelectSupplier). i have a listbox which gets all the supplier names from the access database, and assigns then with the Supplier ID (also from the database). here is the code for the listbox:

Private Sub form_activate()
Set m_colSuppID = Nothing
    Set m_colSuppID = New Collection
    strSQL = "SELECT [supplier_ID], [SupplierName] FROM [Supplier]"
    With con
        Set RP = .Execute(strSQL)
    End With
    With RP
        Do Until .EOF
            lstSupplier.AddItem "" & !supplierName
            m_colSuppID.Add CStr(!supplier_ID), "" & !SupplierName
    End With
End Sub

i need to get the supplier name/ supplier id, to be sent to a text box (frmUpdateProduct.TxtSupplier.text). how would i do this?

10 Years
Discussion Span
Last Post by aparnesh

2 ways :

You can have the Supplier data (Name, Id) as global variables. From form1 (SelectSupp) set the values of the globals and then open form2(UpdProduct). Then u can access the global variables from form2. Frankly, some programmers don't like to use globals, so the second method is better.

Declare a public function in form1 that shows the SuppName.
Public ShowSuppName() as String
ShowSuppName = lstSupplier.Text
End Function

Then call this function from form2 after it has been loaded
txtSupplier.text = form1.ShowSuppName()

Votes + Comments
Thumbs Up Buddy
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.