Listbox Index

abenitez77

Registered User.
Local time
Yesterday, 19:34
Joined
Apr 29, 2010
Messages
141
I have a form that has a listbox. I am calling a procedure from a module and then it closes my form and reopens it. I want my listbox to keep the same location, in other words the selected value will be the same so that it does not loose it's place. Below was my attempt to do this. I get an error msg that What I am doing with ListIndex is not allowed....

Dim LI As Long
Forms("ReportManager")("lstReportName").SetFocus

LI = Forms("ReportManager")("lstReportName").ListIndex
Call ApplyFields(LI)


Sub ApplyFields(ListIdx as long)

DoCmd.Close acForm, "ReportManager", acSaveYes
DoCmd.OpenForm "ReportManager"

Forms("ReportManager")("lstReportName").SetFocus
Forms("ReportManager")("lstReportName").ListIndex = ListIdx

End Sub
 
Why are you closing the form and then open it, what is the purpose doing that?
 
I'm setting the controlsource in several textboxes.
 
I found the answer:

Forms("ReportManager")("lstReportName") = Forms("ReportManager")("lstReportName").ItemData(ListIdx)

Thank you!, Allen Brown
 

Users who are viewing this thread

Back
Top Bottom