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

Query Criteria ... VBA code

Status
Not open for further replies.

soupisgood84

Technical User
Apr 17, 2007
45
US
I have a text_box in a form that will fill a query criteria but when it's blank I want it to insert the following (see below) but I cant seem to get it to work.

Can anyone tell me what I am doing wrong?

Code:
    If Me.txtStartDate = "" Then
    Me.txtStartDate = "1/1/" & Year(Now)
    End If
    If Me.txtEndDate = "" Then
    Me.txtEndDate = Now()
    End If
 
What about this ?
If Not IsDate(Me!txtStartDate) Then
Me!txtStartDate = CDate("1/1/" & Year(Now))
End If
If Not IsDate(Me!txtEndDate) Then
Me!txtEndDate = Date
End If

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

Part and Inventory Search

Sponsor

Back
Top