A
Al
I have a form that I am trying to change the background color for the
controls on that form if the name of the control (text or combo boxes) exist
in a query called "qryauditFieldNames" I am getting an error message on the
dlookup statment. It seems that I have the --- ("" & txt & "", --- syntax
wrong. can some one help me fix this or if some one has a better way to do
this, I will be very appreciative.
thanks
See the code below:
Dim ctl As Control, frm As Form, cbo As ComboBox, txt As TextBox
Set frm = Me.Form
With ctl
For Each ctl In frm.Controls
If ctl.controltype = acComboBox Or ctl.controltype = acTextBox Then
txt = ctl.Name
If ctl.Name = DLookup("" & txt & "", "qryauditFieldNames",
"RevisedField='" & ctl.Name & "'") Then
ctl.BackColor = vbRed
End If
End If
Next
End With
controls on that form if the name of the control (text or combo boxes) exist
in a query called "qryauditFieldNames" I am getting an error message on the
dlookup statment. It seems that I have the --- ("" & txt & "", --- syntax
wrong. can some one help me fix this or if some one has a better way to do
this, I will be very appreciative.
thanks
See the code below:
Dim ctl As Control, frm As Form, cbo As ComboBox, txt As TextBox
Set frm = Me.Form
With ctl
For Each ctl In frm.Controls
If ctl.controltype = acComboBox Or ctl.controltype = acTextBox Then
txt = ctl.Name
If ctl.Name = DLookup("" & txt & "", "qryauditFieldNames",
"RevisedField='" & ctl.Name & "'") Then
ctl.BackColor = vbRed
End If
End If
Next
End With