Open Form after click on ListBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Please,
i have one form with ListBox (List1). In this ListBox has displayed 3
columns with data from querry (date, tank, product). Each data have unique ID.

I want to click on row in ListBox and open another form (of many with
products) with data described in ListBox.
 
On the Double click event of the list box, you can write the code to open
the form, product, with the selected product, using the Wherecondition in the
OnOpen form command line
========================================
Dim MyWhereCondition As String
MyWhereCondition = "[product] = " & Me.[ListBoxName]
Docmd.OpenForm "FormName",,,MyWhereCondition
========================================
If the product field type is string, then use ths
MyWhereCondition = "[product] = '" & Me.[ListBoxName] & "'"

Adding a single quote before and after
========================================
If the Product is not the first column in the list box, then you need to
specify the column number, when it start with 0, so if the product is the
second column, use

MyWhereCondition = "[product] = " & Me.[ListBoxName].Column(1)
 
Thank you,
this is OK but i have about 20 forms with diferent products names. Each row
on ListBox have unique ID (not displayed but in query) and in 3-th column
product name (string). After i click od one row this code must open second
form named like PRODUCT in ListBox and show data with unique ID. Have you
idea?


„Ofer Cohen“ said:
On the Double click event of the list box, you can write the code to open
the form, product, with the selected product, using the Wherecondition in the
OnOpen form command line
========================================
Dim MyWhereCondition As String
MyWhereCondition = "[product] = " & Me.[ListBoxName]
Docmd.OpenForm "FormName",,,MyWhereCondition
========================================
If the product field type is string, then use ths
MyWhereCondition = "[product] = '" & Me.[ListBoxName] & "'"

Adding a single quote before and after
========================================
If the Product is not the first column in the list box, then you need to
specify the column number, when it start with 0, so if the product is the
second column, use

MyWhereCondition = "[product] = " & Me.[ListBoxName].Column(1)

--
Good Luck
BS"D


Igor G. said:
Please,
i have one form with ListBox (List1). In this ListBox has displayed 3
columns with data from querry (date, tank, product). Each data have unique ID.

I want to click on row in ListBox and open another form (of many with
products) with data described in ListBox.
 
Back
Top