J
Joe Wroblewski
I've got a number of forms each of which have command buttons to sort
the forms.
They work just fine. As I add new similar forms I wanted to run the
repetitive code in standard subroutines in a module.
My problem is that I can't use:
Me!OrderBy = strOrderBy
in the standard module.
And when I try to supply the form name I get the following error message:
Run-time Error '2450'
[The Application] can't find the form ' strCurrentFormName'
referred to in a macro expression or Visual Basic code.
My code follows.
Help!
Thanks,
Joe W
MODULE
Public strSortCrit1, strSortCrit2 As String
Public strSortCrit3, strSortCrit4 As String
Public strOrderBy As String
Public strCurrentFormName As String
Public intLen As Integer
Public Sub PrepSort()
strOrderBy = ""
strSortCrit1 = ""
strSortCrit2 = ""
strSortCrit3 = ""
strSortCrit4 = ""
strCurrentFormName = Application.CurrentObjectName
MsgBox "A. strCurrentFormName: " & strCurrentFormName
End Sub
Public Sub RunSort()
strOrderBy = strSortCrit1 & strSortCrit2 & _
strSortCrit3 & strSortCrit4
intLen = Len(strOrderBy)
MsgBox "B. strCurrentFormName: " & strCurrentFormName
If intLen > 0 Then
Forms!strCurrentFormName!OrderBy = strOrderBy
Forms!strCurrentFormName!OrderByOn = True
Else
' Forms!strCurrentFormName!OrderByOn = False
End If
End Sub
' *************************************************************
FORM MODULE
Public Sub SortBySort_Click()
PrepSort
strSortCrit1 = "acSort1, "
strSortCrit2 = "acAssetClass, "
RunSort
End Sub
the forms.
They work just fine. As I add new similar forms I wanted to run the
repetitive code in standard subroutines in a module.
My problem is that I can't use:
Me!OrderBy = strOrderBy
in the standard module.
And when I try to supply the form name I get the following error message:
Run-time Error '2450'
[The Application] can't find the form ' strCurrentFormName'
referred to in a macro expression or Visual Basic code.
My code follows.
Help!
Thanks,
Joe W
MODULE
Public strSortCrit1, strSortCrit2 As String
Public strSortCrit3, strSortCrit4 As String
Public strOrderBy As String
Public strCurrentFormName As String
Public intLen As Integer
Public Sub PrepSort()
strOrderBy = ""
strSortCrit1 = ""
strSortCrit2 = ""
strSortCrit3 = ""
strSortCrit4 = ""
strCurrentFormName = Application.CurrentObjectName
MsgBox "A. strCurrentFormName: " & strCurrentFormName
End Sub
Public Sub RunSort()
strOrderBy = strSortCrit1 & strSortCrit2 & _
strSortCrit3 & strSortCrit4
intLen = Len(strOrderBy)
MsgBox "B. strCurrentFormName: " & strCurrentFormName
If intLen > 0 Then
Forms!strCurrentFormName!OrderBy = strOrderBy
Forms!strCurrentFormName!OrderByOn = True
Else
' Forms!strCurrentFormName!OrderByOn = False
End If
End Sub
' *************************************************************
FORM MODULE
Public Sub SortBySort_Click()
PrepSort
strSortCrit1 = "acSort1, "
strSortCrit2 = "acAssetClass, "
RunSort
End Sub