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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use empty query

Status
Not open for further replies.

Sylvialn

IS-IT--Management
Dec 28, 2000
101
US
i wold like to run a query and check the year column against the Now() date. If the query returns nothing (empty), I would like to assign a new value to a field. For example: If query returns empty, newvalue = "02". How would I write this in the Microsoft Access SQL language?
 
This is how you'd test for it, you can add code to the Else
part of the If-Else-End IF statement to do what you want.

Dim db As DAO.database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("Select * From TableNameHere Where DatePart('yyyy',[DateField]) = DatePart('yyyy',Now())")
With rst
If .RecordCount > 0 Then
MsgBox "Count is " & .RecordCount
Else
MsgBox "No Records"
'Add Code here to do what you want
End If
End With


PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top