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

How to handle a Null Date

Status
Not open for further replies.

ddevil

Technical User
Feb 14, 2006
49
US
I get a run time error "invalid use of Null" on the dtCompleteDate field. Any ideas how I would handle this?

Sub GetRefundData(CriteriaWR)

Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim intEnterWR As Variant

intEnterWR = [CriteriaWR]

strSQL = "SELECT WRInquiry.* FROM WRInquiry Where CD_WR = " & intEnterWR & ";"

Dim stProjectID, stPremise, stArea, stCustName, stJobAddress, stBillName, stBillAdd, stBillCity, stBillState, stBillZip, stOpUnit, stUtilityType, stActivityID, stStatus, stWRDesc, stTypeWR, stJobType As String
Dim dtCompleteDate As Date
Dim intWRNumber As Variant
Dim intTotal As Currency

Set dbs = CurrentDb
Set rst = dbs.OpenRecordset(strSQL, dbOpenDynaset)


With rst

intWRNumber = rst![CD_WR]
stPremise = rst![ID_PREMISE]
stArea = rst![CD_AREA]
stCustName = rst![NM_CONTACT]
stJobAddress = rst![JobAddress]
stBillName = rst![NM_CONTACT]
stBillAdd = rst![Address]
stBillCity = rst![AD_TOWN]
stBillState = rst![CD_STATE]
stBillZip = rst![AD_POSTAL]
stOpUnit = rst![CD_CREWHQ_FIN]
stUType = rst![IND_UTIL]
stActivityID = rst![CD_WR]
stStatus = rst![CD_STATUS]
stWRDesc = rst![DS_WR]
stTypeWR = rst![TP_WR]
stJobType = rst![TP_JOB]
It fails at this point, if the DT_COMPLETE is Null
dtCompleteDate = rst![DT_COMPLETE]
intTotal = rst![QuoteAmount]
stProjectID = rst![CD_WO_INSTL]

Any help would be appreciated. Thanks!
 
Only a Variant may hold a Null value, so either declare dtCompleteDate as Variant or use the Nz function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top