Dirk,
Not quite sure what you mean by conditional formatting. Before I post my
code, allow me to elaborate more fully on the form's design. This form is the
main data entry form for an inventory database of electronic components.
There is a combo box, cboCategory from which the user can select a catagory
to classify the part (ie, "Resistor", "Capacitor", etc). Each category has
several category specific detail fields associated with it. These fields are
either free valued or lookup based. The free valued fields are stored in
tboDetailA, tboDetailB, ..., tboDetailF (where tbo denotes a textbox). The
lookup based values are stored in cboDetail1, ..., cboDetail6). Thus, a
resistor might have a tboDetailA value of "100", and a cboDetail1 value of
"Ohms". The reason for having both free and lookup values is to keep data
consistent between all the parts (ie, a resistor can be any numeric value,
but only "Ohms", "kOhms", or "MOhms"). Since any given category of part will
probably not have all twelve possible detail fields used, the unused fields
are hidden to prevent extraneous and erroneous data from being entered. The
visibilities are set based on twelve text box fields, tboDetailName1, ...,
tboDetailName6, tboDetailNameA, ..., tboDetailNameF. These fields are
populated by the query which drives the form. I have two tables, the
inventory (tblInventory) and a category definition table
(tblCategorySpecificDetailNames) which are joined on a category field. Thus,
changing the category of an item in tblInventory pulls in the correct values
from tblCategorySpecificDetailNames. Now, if one of the tboDetailName fields
is empty (null), it means that that detail is not used by the particular
category, and the corresponding tboDetail or cboDetail field is hidden. And
with that, hopefully the following code is clear. One other thing to note, is
that in addition to the tboDetailName and t/cboDetail fields flickering on
changing the record, a few other controls flicker as well, most notable the
text box tboPartName, which should always be visible. Thanks,
Matt Martin
Private Sub Form_Current()
setVisibilities
' Requery the combo boxes to place the appropriate values for the new
category in
cboDetail1.Requery
cboDetail2.Requery
cboDetail3.Requery
cboDetail4.Requery
cboDetail5.Requery
cboDetail6.Requery
cboPackageStyle.Requery
End Sub
Private Sub setVisibilities()
' Hide detail fields that are not used by the current category
If IsNull(tboDetailName1) Then
cboDetail1.Visible = False
Else
cboDetail1.Visible = True
End If
If IsNull(tboDetailName2) Then
cboDetail2.Visible = False
Else
cboDetail2.Visible = True
End If
If IsNull(tboDetailName3) Then
cboDetail3.Visible = False
Else
cboDetail3.Visible = True
End If
If IsNull(tboDetailName4) Then
cboDetail4.Visible = False
Else
cboDetail4.Visible = True
End If
If IsNull(tboDetailName5) Then
cboDetail5.Visible = False
Else
cboDetail5.Visible = True
End If
If IsNull(tboDetailName6) Then
cboDetail6.Visible = False
Else
cboDetail6.Visible = True
End If
If IsNull(tboDetailNameA) Then
tboDetailA.Visible = False
Else
tboDetailA.Visible = True
End If
If IsNull(tboDetailNameA) Then
tboDetailA.Visible = False
Else
tboDetailA.Visible = True
End If
If IsNull(tboDetailNameB) Then
tboDetailB.Visible = False
Else
tboDetailB.Visible = True
End If
If IsNull(tboDetailNameC) Then
tboDetailC.Visible = False
Else
tboDetailC.Visible = True
End If
If IsNull(tboDetailNameD) Then
tboDetailD.Visible = False
Else
tboDetailD.Visible = True
End If
If IsNull(tboDetailNameE) Then
tboDetailE.Visible = False
Else
tboDetailE.Visible = True
End If
If IsNull(tboDetailNameF) Then
tboDetailF.Visible = False
Else
tboDetailF.Visible = True
End If
End Sub