Sub routine call

mlai08

Registered User.
Local time
Today, 14:38
Joined
Dec 20, 2007
Messages
110
I have to run the following codes in the After Update Event for a number of form fields and can not figure out what varible type to declare in the user defined sub routine. The procedure is the same except that the field name should be a variable.

Private Sub ContractorType_AfterUpdate()
Dim strMsg As String
Dim intchoice As Integer

strMsg = "Do something ......Select OK or Cancel" _

intchoice = MsgBox(strMsg, vbOKCancel, "Message Alert")
If intchoice = vbOK Then ' do nothing
Exit Sub
Else
intchoice = vbCancel
Me.ContractorType.Value = Me.ContractorType.OldValue
Me.ContractorType.SetFocus
End If
End Sub

I tried set up a Sub AlertMsg(Fld As Field) and call this routine from the AfterUpdate event of other fields, say Call AlertMsg(Me!FieldA) but it did not work. Can anyone help me out on this?

Thanks a bunch.
 
If the field name is the variable then it is a string. If you want to do operations on the control that was just updated you could pass in the control.
It seems excessive though, to confirm updates like this at the field level for something like ContractorType.
 

Users who are viewing this thread

Back
Top Bottom