I found this code on a website for VBA coding in Access. I am getting the following error message:
Compile error:
User-defined type not defined
When I run this code: (I changed the font of the section which the VBA compiler is highlighting when giving this error message:
Public Sub ClearForm(frm As Form) 'Pass a form name to it
Dim sMask As String
For Each Control In frm.Controls
If TypeOf Control Is TextBox Or TypeOf Control Is ComboBox Then
Control.Text = "" 'Clear text
End If
If TypeOf Control Is MaskEdBox Then
With Control
sMask = .Mask 'Save the existing mask
.Mask = "" 'Clear mask
.Text = "" 'Clear text
.Mask = sMask 'Reset mask
End With
End If
If TypeOf Control Is DTPicker Then
Control.Date = Date 'Set to current date
End If
Next Control
End Sub
Any help here?
Compile error:
User-defined type not defined
When I run this code: (I changed the font of the section which the VBA compiler is highlighting when giving this error message:
Public Sub ClearForm(frm As Form) 'Pass a form name to it
Dim sMask As String
For Each Control In frm.Controls
If TypeOf Control Is TextBox Or TypeOf Control Is ComboBox Then
Control.Text = "" 'Clear text
End If
If TypeOf Control Is MaskEdBox Then
With Control
sMask = .Mask 'Save the existing mask
.Mask = "" 'Clear mask
.Text = "" 'Clear text
.Mask = sMask 'Reset mask
End With
End If
If TypeOf Control Is DTPicker Then
Control.Date = Date 'Set to current date
End If
Next Control
End Sub
Any help here?