Hello everyone,
I have this code that I use on several forms for a command button that onclick event it brings up the next item in a combo box.
Form:
Private Sub Command73_Click()
Call ComboPlus(CBDate)
CBDate_AfterUpdate <------------------------------------------------------------
End Sub
==============================
Public Sub CBDate_AfterUpdate()
Dim SSos As String
SSos = "format(ldate,'mm/yyyy')= '" & Format(CBDate, "mm/yyyy") & "'"
If gfiltsql <> "" Then
Me.Filter = gfiltsql & " And " & SSos
Else
Me.Filter = SSos
End If
Me.FilterOn = True
Call ShowNewRec(Me)
Me.CBDate.SetFocus
End Sub
================================================
Module:
Public Sub ComboPlus(CBName As Control)
With CBName
.SetFocus
Dim n As Integer
n = .ListIndex
If n = .ListCount - 1 Then
n = 0
CBName = .ItemData
Else
CBName = .ItemData(n + 1)
End If
End With
End Sub
'===================================
My Question:
How can I move the line CBDate_AfterUpdate to the module and be able to use it with different forms?
Appreciate your help.
I have this code that I use on several forms for a command button that onclick event it brings up the next item in a combo box.
Form:
Private Sub Command73_Click()
Call ComboPlus(CBDate)
CBDate_AfterUpdate <------------------------------------------------------------
End Sub
==============================
Public Sub CBDate_AfterUpdate()
Dim SSos As String
SSos = "format(ldate,'mm/yyyy')= '" & Format(CBDate, "mm/yyyy") & "'"
If gfiltsql <> "" Then
Me.Filter = gfiltsql & " And " & SSos
Else
Me.Filter = SSos
End If
Me.FilterOn = True
Call ShowNewRec(Me)
Me.CBDate.SetFocus
End Sub
================================================
Module:
Public Sub ComboPlus(CBName As Control)
With CBName
.SetFocus
Dim n As Integer
n = .ListIndex
If n = .ListCount - 1 Then
n = 0
CBName = .ItemData
Else
CBName = .ItemData(n + 1)
End If
End With
End Sub
'===================================
My Question:
How can I move the line CBDate_AfterUpdate to the module and be able to use it with different forms?
Appreciate your help.