Hi all, i am new to this site and have heard great things.

i feel i might have been thrown in the deep end of visual basic and would appreciate any help or just to know weather i am in the right direction.

I have an external database file which i created a macro to access which offers me a box to enter two dates, >= date x and <=date z. I need to replace these dates with inputted dates via input boxes on a userform which loads on excel open. Difficult?

What ive got.

--------------------------------------------------------------------------------------------------


Private Sub Workbook_Open()
    DateFilter.Show
End Sub

Private Sub CommandButton1_Click()

Dim TBStartDates As Date
Dim TBEndDates As Date

    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array(Array( _
        "ODBC;DSN=Visual FoxPro Tables;UID=;;SourceDB=p:\;SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;Null=Yes;Deleted=yes" _
        ), Array(";")), Destination:=Range("$A$1")).QueryTable
        .CommandText = Array( _
        "SELECT slotapp.slotdate" & Chr(13) & "" & Chr(10) & "FROM slotapp slotapp" & Chr(13) & "" & Chr(10) & "WHERE (slotapp.slotdate>='20070101' And slotapp.slotdate<='20070707')" _
        )
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .Refresh BackgroundQuery:=False
    End With
End Sub
I have tried replacing the two current dates with things like TBStartDates.value and TBEndDates.value??

or heading along the lines of

Criteria1:=">=" & Format(Me.TBStartDates.Value, "mm/dd/yy"), Operator:=xlAnd, _
Criteria2:="<" & Format(Me.TBEndDates.Value, "mm/dd/yy")

but i am clueless and close to giving up.

thanks

Rob