Use first record in list box in a where statement

TimTDP

Registered User.
Local time
Today, 21:26
Joined
Oct 24, 2008
Messages
213
I have code that adds a record to a list box. I then select the new record using
Code:
Me.lstPickingSlipsCreated.Selected(lrow:=0) = True
The new record is always the first record, and headers are not shown

On the form I have a button to print a report for the record selected. I create a "where" clause like this
Code:
Wclause = "OrderPickId = " & Me.lstPickingSlipsCreated
but the Wclause does not return the correct OrderPickId of the record selected in the first line of code. It does if I click a record in the list box.

How can I modify my first line of code to so that the recorded is selected as if I had selected it by clicking on it?

Many thanks
 
Hello TimTDP.. Where do you have the LOC to set the first row as selected?

If you are confident that you always have to use the First Row.. You can try..
Code:
Wclause = "OrderPickId = " & Me.lstPickingSlipsCreated.ItemData(0)
 
This is my problem!

When I add a new record then I want the first row.
However I also need to allow the user to select any record from the list box, and the WClause must reflect this
 
Where do you have the LOC to set the first row as selected?
Code:
Me.lstPickingSlipsCreated.Selected(lrow:=0) = True
Multi select = None
 
Okay my bad, should have asked.. On which event have you placed the code to set the first row as Selected = True?
 
I have a command button on the form that, after running code, creates the new record in the listbox.
I run Me.lstPickingSlipsCreated.Selected(lrow:=0) = True at the end of this code. I do not run it from an event.
 
Found the solution!

Me.lstPickingSlipsCreated= Me.lstPickingSlipsCreated.ItemData(0)
 

Users who are viewing this thread

Back
Top Bottom