Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

public function

Status
Not open for further replies.

pooterpooter

Technical User
Oct 7, 2005
11
BG



I have a very nice function that works well,but for some reasons in my code i want to make my function public and i get always mistaked saying that the filed branch cannot be found.Could you help me rearrange the function to be public ?




Private Function lop() , placed in the subform FOrder details extended
Dim OfficeBranch As Control
Dim OfficeItems As Control
Set OfficeBranch = Me.Controls("Branch" & (Me.Parent.office - 1))
Set OfficeItems = Me.Controls("Items" & (Me.Parent.office - 1))
If Me!size > 18 Then
OfficeBranch = OfficeItems
Else
OfficeBranch = OfficeItems / Me!pack
End If
Parent!current.Requery
End Function




Public Function lop()

Dim MyForm As Form
Dim MySubform As Form


Set MyForm = Forms!FOrderInformation
Set MySubform = [Forms]![FOrderInformation]![Forder details extended].[Form]
Dim OfficeBranch As Control
Dim OfficeItems As Control
Set OfficeBranch = MyForm.Controls("Branch" & (MyForm.office - 1))
Set OfficeItems = MyForm.Controls("Items" & (MyForm.Parent.office - 1))
If MySubform!size > 18 Then
OfficeBranch = OfficeItems
Else
OfficeBranch = OfficeItems / MySubform!pack
End If
MyForm!current.Requery

End Function



 
If your function is defined within a form, then you must use the correct syntax to call the function (i.e. Form_YourFormName.YourFunctionName).

However, you would be better off creating a new module and placing your function inside the new module. And name your module something like this: baslop (Function would still be named lop)
 
I have a module with lots of useful functions (many are called from queries) which are all public and avaiable as utilities wherever I need them.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top