Christineeve
Programmer
Hi!
I've done this before but for some reason today, I can't find my old source code, and bonus...I'm having a mental block and can't figure this out.
I'm trying to simply return one item that is selected in a listbox. I need to eventually pass it into my query, but I feel confident I can do that part.
When I select my date on the form, #07/31/2009#, this code goes to the first line entry in the control and returns that date, not my selected date. In this case #12/31/2006, instead of 7/31/2009.
I should know why but I don't. I feel foolish in asking because I'm sure it's obvious, but I'm overlooking the problem. Am I missing a count to increment?
Thanks for any help. I appreciate your help.
Here's my code:
'CMD is the name of the listbox control
'It's improper naming convention, I'm stuck with it.
'I'm developing a report that piggybacks off
'this existing stuff.
Dim lngcloop As Long
For lngcloop = 0 To (Me.CMD.ListCount - 1)
Me.CMD.Selected(lngcloop) = True
strCurrentMDate = Me.CMD.ItemData(lngcloop)
Exit For
Next lngcloop
MsgBox strCurrentMDate
I've done this before but for some reason today, I can't find my old source code, and bonus...I'm having a mental block and can't figure this out.
I'm trying to simply return one item that is selected in a listbox. I need to eventually pass it into my query, but I feel confident I can do that part.
When I select my date on the form, #07/31/2009#, this code goes to the first line entry in the control and returns that date, not my selected date. In this case #12/31/2006, instead of 7/31/2009.
I should know why but I don't. I feel foolish in asking because I'm sure it's obvious, but I'm overlooking the problem. Am I missing a count to increment?
Thanks for any help. I appreciate your help.
Here's my code:
'CMD is the name of the listbox control
'It's improper naming convention, I'm stuck with it.
'I'm developing a report that piggybacks off
'this existing stuff.
Dim lngcloop As Long
For lngcloop = 0 To (Me.CMD.ListCount - 1)
Me.CMD.Selected(lngcloop) = True
strCurrentMDate = Me.CMD.ItemData(lngcloop)
Exit For
Next lngcloop
MsgBox strCurrentMDate