Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

open form with specific values including combobox from listbox

Status
Not open for further replies.

ben1977

Technical User
Jul 25, 2011
6
CH
Hi,

I have two froms. The first includes a listbox with customer related information. If I click on a specific data in the listbox I want to open a second from which includes a dropdown (same value as listbox before; with firstname and lastname) and also a subform with the whole address.

My problem is when I click on the listbox the dropdown in the new form has the same ID as in the listbox, but is somehow not active as the subform with the address has not the same ID. Just when I click again on the dropdown the address in the subfrom changes to the correct ID

What kind of vba code do I need to open the second form and adapt the selected ID from the listbox in the combobox and the subform?

By the way: I can't link the form and the subform with the ID, as I want to change the customer in the dropdown to receive other results in the subform.

thanks for your answers
 
Hi,

To be more specific:

Form 1 (clientlist) contains:
clientlist.listbox (ID, firstname, lastname....)

Form 2 (client)
Header: cmb_client (ID, firstname, lastname)

Subform: (clientdetail) contains:
ID, firstname, lastname, address, telefon ...)
 
Hi,

Here the Code string from the listbox:

***
Private Sub clientList_Click()
strCriteria = "client_ID = " & Me.clientList
DoCmd.OpenForm "frm_client", acNormal, , strCriteria
End Sub
***

Here the code string for form "frm_client":

***
Private Sub Form_Load()
Me.cmb_client = Me.clientID
Me.cmb_client.Requery
Me.frm_clientdetail.Requery
End Sub

***

Here the code string for combobox cmb_client:

***
Private Sub cmb_client_AfterUpdate()
Me.cmb_client.Requery

Me.frm_clientdetail.Filter = "client_ID = " & Me.cmb_client
Me.frm_clientdetail.Form.FilterOn = True
End Sub

***

Hope that helps you a little bit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top