passing a name of the form to a function

  • Thread starter Thread starter vukblagojevic
  • Start date Start date
V

vukblagojevic

I have a function, and would like to pass a name of the form to it so
I can search for a particular name of a page of the form:

Public Sub Multipage_page_finder(form As String, page_name As String)

MsgBox form
MsgBox page_name
For i = 0 To (Controls(form).MultiPage_main.pages.count - 1)
If Controls(form).MultiPage_main.pages(i).Name = page_name Then
'MsgBox "found"
Controls(form).MultiPage_main.Value = i
End If
Next i

End Sub

What I have to modify?
 
I have a function, and would like to pass a name of the form to it so
I can search for a particular name of a page of the form:

Public Sub Multipage_page_finder(form As String, page_name As String)

MsgBox form
MsgBox page_name
For i = 0 To (Controls(form).MultiPage_main.pages.count - 1)
If Controls(form).MultiPage_main.pages(i).Name = page_name Then
'MsgBox "found"
Controls(form).MultiPage_main.Value = i
End If
Next i

End Sub

What I have to modify?

You cannot use a reserved VBA word such as "form" as a variable name.
 
Try
Public Sub Multipage_page_finder(frm as form , page_name As String)

then refer to form as frm.

Damon
 
Back
Top