Requery not executing?

L

Lee Hunter

The follwing code is used to change the base query for a listbox, changing
the WHERE clause to a known value, but an examination of the listcount after
the requery confirm that the query returned zero records.

qryStr = "SELECT Master.Part FROM Master ORDER BY Master.Part WHERE
(((Master.Part)=" & """" & qrystr1 & """" & "));"
MsgBox qryStr 'confirms the known value
Me.Part.RowSource = qryStr
Me.Part.Requery
recs = Me.Part.ListCount
MsgBox recs 'returns zero
MsgBox Me.Part.Value 'is NULL

Can someone please suggest a solution?
Remember that the where clause contains a known value, confirmed by using
the same query as the original RowSource.

Thanks.
 
T

Tim Ferguson

qryStr = "SELECT Master.Part FROM Master ORDER BY Master.Part WHERE
(((Master.Part)=" & """" & qrystr1 & """" & "));"

The query is a bit redundant isn't it? It'll just return qrystr1 if it
exists and nothing if it doesn't.

What are you really trying to do?

B wishes


Tim F
 
L

Lee Hunter

Tim,

Thanks for your reply.

What I have is a part number description table with very long descriptions.

Each description may have many part numbers associated with it.

My intenet is to fill list box one with only descriptions and when the users
picks a description fill list box 2 with all the corresponding part numbers.

I don't use one big list box because it would be wider than the form.

Can you help me out?

Lee
 
L

Lee Hunter

Thanks to all who helped!

For all of you, the solution was just a matter of vba code syntax inserting
the SELECT staement into the RowSource Field. One that was done right,
everything works like a charm.

Thanks again.
 
Top