Using forms with a query

S

Stu

I have a form with a combo box which inputs a parameter
to a parameter query. It works, but when I close the form
I get an "Index or primary key cannot contain a null
value" error. There are no null values in the combo box
when the form is closing, and there are no null values in
the table from which the combo box gets its list. Why is
the form trying to input a null value when it's closing?
 
M

Martin Walke

Stu,

Is the query being run when the combo value changes? It may be that when the
form closes, it forces the value of the combo box to a null, thereby causes
the event to fire? You may have to surround the event change code with some
logic to prevent this.

Martin
 
S

Stu

No, the query runs successfully after the combo value is
changed. I have a button on the form which runs a report
based on the parameter specified by the form. The form
window stays open when the report appears. Its when I
close the form window that I get the error message. I
have no VB code in this. There must be a way to fix this
without writing VB code.
 
M

Martin Walke

Maybe this is a red herring. Perhaps the combo value etc has nothing to do
with the error message. Unless the combo value IS the index/primary key
field, why is it moaning about it? Perhaps there's something else (like the
index/primary key field) that's getting set to null for some reason. e.g.
adding new record, seeking to a non-existing record?

Martin
 
Top