Show all machines or only one

G

Guest

Hi,

I have the following question:

I have a table with all kinds of data including the machine number. I also
designed a form with a text field where you can enter a machine number. If
there is no machine number filled in, the query should show all data for all
machine numbers. In the case there is a machine number filled in, the query
should show only the data for the entered machine number.

In the criteria (in the query) for the machine number I entered the
following: IIf([Forms]![F_Start]![MachineNumber]="";Like
"*";[Forms]![F_Start]![MachineNumber]). When I enter a machine number in the
text field this works ok, only the relevant machine number data is displayed.
When I enter nothing in the text field, the query doesn't work correct. No
records are shown.

If I try only the criteria Like "*" (without the iff function and the rest)
the query shows all data for all machine numbers.

What am I doing wrong?

Thanks in advance,

JeroenM.
 
J

John Spencer

Try just the following

Like NZ([Forms]![F_Start]![MachineNumber],"*")

That should return all records with a value in the field when you leave
[Forms]![F_Start]![MachineNumber] blank. It won't return records where
theMachine number field is null (blank).
 
G

Guest

Thanks, works great.

JeroenM.

John Spencer said:
Try just the following

Like NZ([Forms]![F_Start]![MachineNumber],"*")

That should return all records with a value in the field when you leave
[Forms]![F_Start]![MachineNumber] blank. It won't return records where
theMachine number field is null (blank).

--
John Spencer
Access MVP 2002-2005, 2007

JeroenM said:
Hi,

I have the following question:

I have a table with all kinds of data including the machine number. I also
designed a form with a text field where you can enter a machine number. If
there is no machine number filled in, the query should show all data for
all
machine numbers. In the case there is a machine number filled in, the
query
should show only the data for the entered machine number.

In the criteria (in the query) for the machine number I entered the
following: IIf([Forms]![F_Start]![MachineNumber]="";Like
"*";[Forms]![F_Start]![MachineNumber]). When I enter a machine number in
the
text field this works ok, only the relevant machine number data is
displayed.
When I enter nothing in the text field, the query doesn't work correct. No
records are shown.

If I try only the criteria Like "*" (without the iff function and the
rest)
the query shows all data for all machine numbers.

What am I doing wrong?

Thanks in advance,

JeroenM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top