Record source for subform in Access 200

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My form is called frmEquip. On this form I have a combo box called
cboLinePM1 and a subform. I want to control the records displayed on the
subform by the selection made in cboLine so in the appropriate field of the
subform's record source query I put this code: "Forms!frmEquip!cboLinePM1".
Everything works fine until I select a null in cboLinePM1. The subform does
not recognize the null. How can I get it to recognize the null?
 
The issue is that Null does not equal anything -- not even another Null. If
you think of null as meaning "Unknown", the question, "Does one Unknown
equal another Unknown?" receives the answer "Unknown."

You could try changing the WHERE clause of the SQL view of your subform's
query to read something like this:
WHERE (IIf(Forms!frmEquip!cboLinePM1 Is Null, LinePM1 Is Null, False) OR
(LinePM1 = Forms!frmEquip!cboLinePM1))
 
What did you want the SubForm to do when it sees a Null? I suppose you could
use the Nz(Forms!frmEquip!cboLinePM1,0) function which should return a zero if a
null is encountered. Or you could have it return a zero length string "".

My form is called frmEquip. On this form I have a combo box called
cboLinePM1 and a subform. I want to control the records displayed on the
subform by the selection made in cboLine so in the appropriate field of the
subform's record source query I put this code: "Forms!frmEquip!cboLinePM1".
Everything works fine until I select a null in cboLinePM1. The subform does
not recognize the null. How can I get it to recognize the null?

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
The data in this field represents the various lines of equipment in
different departments of my company - 1, 2, etc. Not all equipment in a
department is assigned to a line though so the field in the table is left
blank when the equipment is not assigned. The records in the subform are a
result of selecting a department and line from two different comb boxes. The
problem arises when a null is selected from the line combo box (cboLinePM1).
The subform does not recognize the null. How can I get the subform to see a
zero length string ("") when a null is selected in the combo box?
 
Did you look up the Nz() function? Nz(Forms!frmEquip!cboLinePM1,"")

The data in this field represents the various lines of equipment in
different departments of my company - 1, 2, etc. Not all equipment in a
department is assigned to a line though so the field in the table is left
blank when the equipment is not assigned. The records in the subform are a
result of selecting a department and line from two different comb boxes. The
problem arises when a null is selected from the line combo box (cboLinePM1).
The subform does not recognize the null. How can I get the subform to see a
zero length string ("") when a null is selected in the combo box?

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
Back
Top