J
Jan DOUMEN
Hi,
is there a generic way to add events to controls on a form using
vba code?
I was thinking of code under the 'on current' property of the main
form, which cycles through all the controls on the form and sets
coding behind the 'on click' event.
I'm able to change the obvious properties like formating ...
Function ColorFields(frm As Form)
Dim ctl As Control
Dim rqrd As Boolean
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Then
rqrd = CurrentDb.TableDefs(frm.RecordSource).Fields(ctl.Name).Required
If rqrd Then
If IsNull(ctl.Value) Then
ctl.BackColor = 8454143
Else
ctl.BackColor = 12713983
End If
Else
ctl.BackColor = 16777215
End If
End If
Next
End Function
.... which makes life a little easier so that I don't have to
go through all the controls manually. But how do I proceed
when I want to add coding under the 'on click' setting in
a similar automated way?
Any suggestions?
Thanks in advance,
is there a generic way to add events to controls on a form using
vba code?
I was thinking of code under the 'on current' property of the main
form, which cycles through all the controls on the form and sets
coding behind the 'on click' event.
I'm able to change the obvious properties like formating ...
Function ColorFields(frm As Form)
Dim ctl As Control
Dim rqrd As Boolean
For Each ctl In frm.Controls
If ctl.ControlType = acTextBox Then
rqrd = CurrentDb.TableDefs(frm.RecordSource).Fields(ctl.Name).Required
If rqrd Then
If IsNull(ctl.Value) Then
ctl.BackColor = 8454143
Else
ctl.BackColor = 12713983
End If
Else
ctl.BackColor = 16777215
End If
End If
Next
End Function
.... which makes life a little easier so that I don't have to
go through all the controls manually. But how do I proceed
when I want to add coding under the 'on click' setting in
a similar automated way?
Any suggestions?
Thanks in advance,