Update query should not fire if prompt is null

R

Randy

MS Access 2000. I have an update query that has a prompt for a date. User
is supposed to enter a date, then it is updated to the table. But if the
user forgets to enter a date the record is updated minus a date. The record
will be missing the date. How do I prevent the query from running if the
date prompt is null? Thanks.
 
J

John Spencer

Assumption is that you are using a parameter.

The update query is always going to run. But you might be able to prevent is
from changing any data

UPDATE SomeTable
SET fieldx = [Enter Date]
WHERE [Enter Date] is not Null

or another possible method

UpDate SomeTable
Set fieldx = NZ([Enter Date],[Fieldx])

I would use a form to get the input and call the update query from a button on
the form. That way you could check if the value entered was a valid date
before attempting to execute the query.

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County
 

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