Fill listbox2 From listbox1 pick (1 Viewer)

TheOldGuy

New member
Local time
Today, 06:04
Joined
Sep 23, 2019
Messages
7
Hello,
I thought that this problem was resolved but no.
I dug a little deeper and discovered that the DAO 3.6 library was missing or corrupted so I choose the adob 2.5 referance, still did not work
The combobox pick filling Listbox1 does work though.
I think I have changed all references to DAO to ADOB

Public FLDNUM As Integer
Public STRSQL As String
Public STRENG As String
Public STRTYPE As String

Public FLD As Field

Public RS As ADODB.Recordset
Public db As ADODB.Connection
Public QDF As ADODB.Connection

Public NUM As Integer

This is the one that still works

Set db = New ADODB.Connection


ENGNUM = Me.CMBENGNEER.Column(0)

STRSQL = "SELECT DISTINCT MATERIAL_NEEDED.ENGID, MATERIAL_NEEDED.ENGINEER, MATERIAL_NEEDED.TYPE, MATERIAL_NEEDED.TYPES_AVAILABLE " _
& "FROM MATERIAL_NEEDED INNER JOIN Q_Engineer ON MATERIAL_NEEDED.ENGID = Q_Engineer.ENGID " _
& "WHERE (((MATERIAL_NEEDED.ENGID)= " & ENGNUM & "))"


Me.LstTYPE.RowSource = STRSQL
Me.LstTYPE.Requery

Set db = Nothing

This one no longer works

Set db = New ADODB.Connection

ENGNUM = Me.LstTYPE.Column(0)
STRTYPE = Me.LstTYPE.Column(3)

STRSQL = "SELECT DISTINCT MATERIAL_NEEDED.ENGID, MATERIAL_NEEDED.TYPES_AVAILABLE, MATERIAL_NEEDED.GRADES_AVALABLE, MATERIAL_NEEDED.SUBTYPES_AVAILABLE " _
& " FROM MATERIAL_NEEDED INNER JOIN Q_Engineer ON MATERIAL_NEEDED.ENGID = Q_Engineer.ENGID " _
& " WHERE ((MATERIAL_NEEDED.TYPES_AVAILABLE)='" & STRTYPE & "') AND (MATERIAL_NEEDED.ENGID)= " & ENGNUM & "));"


Me.LstSUBTYPE.RowSource = STRSQL
Me.LstSUBTYPE.Requery

Set db = Nothing

Baffled
 

Ranman256

Well-known member
Local time
Today, 09:04
Joined
Apr 9, 2015
Messages
4,339
Make q1 show 2 columns, caption (for the user) and a query (to fill the list box).
User picks an item in the listbox/combo, then the listbox2 fills with the query.

Listbox2.rowsource= listbox1

That's all the code needed.
 

TheOldGuy

New member
Local time
Today, 06:04
Joined
Sep 23, 2019
Messages
7
W
Thanks will give it a try
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:04
Joined
May 7, 2009
Messages
19,175
you are creating a Connection that you are not using?
 

Users who are viewing this thread

Top Bottom