That should work.
Some things to check:
1. Any broken references?
http://allenbrowne.com/ser-38.html
2. Does your code compile?
(Compile on Debug menu, in the code window.)
3. Try adding the Call keyword, i.e.:
Call SelectAnItem(frm!lstModel, strLineItem)
4. Set a breakpoint immediately before this Call line, and use the Immediate
Window (Ctrl+G) to ask Access what's going on, e.g.:
Debug.Print ctl.Name
Debug.Print ctl.ControlType
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Clyde" <(E-Mail Removed)> wrote in message
news:0B7F74D3-7870-4AEB-B52A-(E-Mail Removed)...
> I have a funtion like this:
> Function SelectAnItem(By Ref ctl as control, strItem as string)
>
> Have been successfully calling like this:
> SelectAnItem(frm!lstModel, strLineItem)
> where frm is dimmed as Form and lstModel is a list box.
>
> All of a suddent this code now passes the ctl argument as the value of the
> list box and of course the function fails. I have no idea what I changed
> where to cause this change in behavior, but I know that ?frm!lstModle
> obviously is the value of the selection. Makes me wonder how it ever
> worked.
>
> In the calling procedure I have tried Set ctl = frm!lstModel (diming ctl
> as
> control) and the result is the same.
>
> So... how do I pass the control frm!lstModel to the function as a control?
>
> Thanks in advance.
> --
> Clyde