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

VBA does not recognize field 1

Status
Not open for further replies.

0212

Technical User
Apr 2, 2003
115
US
Hi, I am trying to filter a form from a dialog box. In using DateAdd, I could not get vba to understand that I have an SQL statement and the DataAdd Function i.e. DateAdd("d",30,[RADue]). It got confused with the quotes. So I tried to create a variable called 'DateCheck'. I then equated it with the above DateAdd Function. However, now it doesn't recognize my field (from the form I have opened). Can anyone help?

Private Sub Ok_Click()
Me.Visible = False
Dim strWhere As String
Dim DateCheck As Date
DateCheck = DateAdd("d", 30, [RADue])
strWhere = "1=1 "
strWhere = strWhere & " AND [PEID]=" & Me![PE_ID] & _
" AND [BUID]=" & Me![BU_ID]
Select Case Me.RptType
Case 1
Select Case Me.OvrDue
Case 1
StrWhere = strWhere & " AND DateCheck => Date()" & _
" AND [RADue]< Date() " & _
" AND [RAComp]Is Null
 
StrWhere = strWhere & " AND [RADue] >= (Date()-30)" & _
" AND [RADue] < Date() " & _
" AND [RAComp] Is Null "

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, thank you again!! I really appreciate your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top