Hi Susan,
Sorry for not being clearer. It is probably because I am new to all
this.
The problem can really be condensed down to is there a way to return a
record
when using a parameter query if the record has a null value in the
field
which the criteria (parameter) is used on?
In brief (with just one report, table, field, etc as an example), I
have a
switchboard that allows you to open a report and filter the results
based
on
the value in a combo box (populated from a field in a table). The combo
box
is null unless someone chooses a value, and the report uses a query as
the
record source wherein the "criteria" for the field is
Like NZ([forms]![switchbord]![combobox],"*")
Thus if no value is chosen in the combo box, then the criteria in the
query
is "*", which is all records, EXCEPT those with a null value for the
field
the criteria is working on. This will of coarse mean that certain
records
will be lost in the Report simply because they had a null value in the
combo
box (resulting in a "*" in the query criteria).
I really don't think that there is any easy way around this at the
form/query level but I was thinking that through ADO I could loop
through
the
records in the tables and change all null values to a string value-
which
I
am just now exploring on how to use. But before I did this I just
wanted
to
check to be sure that there was not some easy way to use a parameter
query
on
records that had null values and still be able to return them.
Thanks and I hope this helps!
:
salmonella,
You're getting me all confused here - is this combo box set on a
single
field lookup table or something? That's the only way I can figure that
the
SQL "Select * from Table" is not going to return records with a null
value
in some field or another.
What's the SQL statement you are trying to fill out?
What's the basis of the combo box? Is it a table or a value list?
Susan,
You got me here. I don't have a clue what to do with this (unless I
use
it
behind the form or combo box). Also, the problem is not whether the
combo
box
is null- it is always null unless a value is selected to use as the
criteria
in the query. Therefore Like [forms]![reports_switch_main]![combo44]
in
the
criteria will return all records based on the chosen value in the
combo
box
or, if the combo box is null, all records from the table EXEPT
those
with
a
null value- because the "*" will not return a record with a field
with
a
null
value. Thus you can see the problem- if i have a null value in a
table's
field and the combo box for it does not contain a value, even though
it
is
not suposed to be involved in filtering the returned data, all
records
with
null values for that field will not be returned!!!
Thus it seems that I must either not use the "*" in the criteria or
no
null
values can be in the tables. i fixed the problem for a few forms
with
code
but it is just too complicated to do the entire db this way. Again,
it
seems
that working with record sets is the cleanest way to do this.
Any thoughts........???
thanks.........
:
Ok, sorry, let's test the combo box for null, not the data:
'''''''''''''''''''''
dim strSQL as String
If isNull(Me.ComboBox) then
strSQL = "SELECT * from YourTable"
Else
strSQL = ".............Whatever your original query
was........."
End If
'''''''''''''''''''''
Just realized that I had tried this (see previouse message)
before.
It
won't
work because the query will return a record just because it is
null.
Back
to
square one! Is there anyway to return all records, null or not,
if a
parameter is not chosen??
thanks
:
Don't change your data! You can use the Nz function instead to
return
a
value where records are Null. This page shows how:
http://www.techonthenet.com/access/functions/advanced/nz.php
--
hth,
SusanV
I am using a parameter query that gets its values from combo
boxes.
However,
null values will cause records not to be returned. It is not
feasible
to
change the null values at the form level so I thought I would
use
ADO
to
change the null values to "No Data" at the record level. Now
my
questions
1. Does anyone have a bit of generic code that I can reference
for
looping
through a record set and changing null values to strings? Or
is
there a
simpler way of doing it?. I assume it would be something like
a"
for
each-in"
statement with a "if (null) then ("no-data")" However I am
just
learning
Vba
I would REALY appreciate a little push on the syntax
2. I am thinking of splitting the database. Do I need to do
anything
special, say in defining the connection, if I am connecting to
linked-tables?
Many thanks!