Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Default Values in a Query

Status
Not open for further replies.

BobChesh

Technical User
Dec 13, 2001
39
GB
I want to use an update query to amend data in a table. One of the fields is in Text format, and I want to update this field to show the text "Week Ending" followed by a date (in text format).

I can use the square brackets [] to open an User Input Box to insert the required text, but I would like this to default to a text value of say yesterday (Date()-1), rather than a blank value

Can this be done in Access 97?
 
Sure. Set the 'Update to:" value for the field to
"Week Ending : " & Format(Dateadd("d",-1,Date(),"mm/dd/yyyy")

Output will look like "Week Ending : 02/17/2002"
 
The if it's blank part can be done with an IIF statement.

IIf(IsNull(Value), True part, False part)

Or

Nz(Value, "Week Ending : " & Format(Dateadd("d",-1,Date(),"mm/dd/yyyy")

Steve King


Growth follows a healthy professional curiosity
 
Robert,

It works fine, but maybe I didn't explain myself enough.

I want the default value to shown, prior to "OK" (Like and Input Box), as it is possible that I want to set the W/E to be today-2, (when I update on a Tuesday, say), so I don't really want to change the query all the time, just to be able to accept the default, or to change it, without using an Input Box.

Hope this makes more sense

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top