Question : Setfocus in a function

I am trying to find a record in a function. I have multiple forms like this so I thought I'd do it in a function. This does not work..

Function findcase(caseid As String)
ActiveForm.accid.SetFocus
DoCmd.FindRecord caseid
ActiveForm.local_case_id.SetFocus
End Function

I know it works to use forms![formname]![accid].setfocus but how do I pass it?
I tried to add a second parameter but it kept asking for an =.

This should be easy - why am I so frustrated?

Answer : Setfocus in a function

try

Function findcase(caseid As String, sForm as string, sControl as string)
Forms(sForm)(sControl).SetFocus
DoCmd.FindRecord caseid

End Function

to use

call findcase("1234","NameOfForm","NameOfControl")

Random Solutions  
 
programming4us programming4us