happyaslarry
New member
- Local time
- Today, 05:33
- Joined
- Mar 3, 2007
- Messages
- 20
Newbie to programming needs help...
I need to run a module and a class module at the same time with the afterupdate event of a text box. The module handles the entry of percentages in the text box to make them easier and the code I wish to run updates the display of other text boxes on the same form.
Public Function MakePercent(txt As TextBox)
On Error GoTo Err_Handler
'Purpose: Divide the value by 100 if no percent sign found.
'Usage: Set the After Update property of a text box named TxtDiscount to:
' =MakePercent([txtDiscount])
If Not IsNull(txt) Then
If InStr(txt.Text, "%") = 0 Then
txt = txt / 100
End If
End If
Exit_Handler:
Exit Function
Err_Handler:
If Err.Number <> 2185 Then 'No Text property unless control has focus.
msgbox "Error " & Err.Number & " - " & Err.Description
End If
Resume Exit_Handler
End Function
Private Sub txtDiscount_AfterUpdate()
[txtGross] = [txtNet] * (1 + [cboVAT])
[txtNetDiscounted] = [txtNet] * (1 - [txtDiscount])
[txtGrossDiscounted] = [txtGross] * (1 - [txtDiscount])
[txtNetMarkup] = [txtNetDiscounted] * (1 + [txtMarkup])
[txtGrossMarkup] = [txtGrossDiscounted] * (1 + [txtMarkup])
'Me.Refresh
End Sub
I assume I can run the module from within the VBA code for the class module but I cannot figure out how.
Any help would be greatly appreciated.
I need to run a module and a class module at the same time with the afterupdate event of a text box. The module handles the entry of percentages in the text box to make them easier and the code I wish to run updates the display of other text boxes on the same form.
Module;Public Function MakePercent(txt As TextBox)
On Error GoTo Err_Handler
'Purpose: Divide the value by 100 if no percent sign found.
'Usage: Set the After Update property of a text box named TxtDiscount to:
' =MakePercent([txtDiscount])
If Not IsNull(txt) Then
If InStr(txt.Text, "%") = 0 Then
txt = txt / 100
End If
End If
Exit_Handler:
Exit Function
Err_Handler:
If Err.Number <> 2185 Then 'No Text property unless control has focus.
msgbox "Error " & Err.Number & " - " & Err.Description
End If
Resume Exit_Handler
End Function
This is the local code I wish to run;Private Sub txtDiscount_AfterUpdate()
[txtGross] = [txtNet] * (1 + [cboVAT])
[txtNetDiscounted] = [txtNet] * (1 - [txtDiscount])
[txtGrossDiscounted] = [txtGross] * (1 - [txtDiscount])
[txtNetMarkup] = [txtNetDiscounted] * (1 + [txtMarkup])
[txtGrossMarkup] = [txtGrossDiscounted] * (1 + [txtMarkup])
'Me.Refresh
End Sub
I assume I can run the module from within the VBA code for the class module but I cannot figure out how.
Any help would be greatly appreciated.