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

Problem with excel date and VB dtpicker

Status
Not open for further replies.

jlroeder

Technical User
Sep 18, 2009
91
US
I am having trouble with my auto filter displaying the dates. The column format is set for date mm/dd/yyyy with vb coding

Columns("O:O").Select
Selection.NumberFormat = "mm/dd/yyyy"


My form date selectors are

Private Sub DTPicker1_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker1.CustomFormat = "mm/dd/yyyy"
End Sub

Private Sub DTPicker2_CallbackKeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal CallbackField As String, CallbackDate As Date)
DTPicker2.CustomFormat = "mm/dd/yyyy"
End Sub


And my auto filter is

ActiveSheet.ListObjects("Table_Query_from_TMS_ODBC").Range.AutoFilter Field:= _
15, Criteria1:=">=" & DTPicker1, Operator:=xlAnd, Criteria2:="<=" & DTPicker2

My auto filter will run, but will not filter the dates. Is this a date format issue between excel and visual basic?
 
Hi,

Break on the AutoFilter statement and use the Watch Window to discover what's going on with your 2 criteria values.
 
Expression not defined in context for both Criteria 1 and 2.
 
The dtpicker1 and 2 are listed under my userform1. My autofilter is listed under module1. Everything is located on my vba project.
 
Your AutoFileter is on a Worksheet!

So you date picker must reference the Userform.

userForm1.DTPicker1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top