MS Access stLinkCriteria Between Dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JpjVB
    New Member
    • Aug 2010
    • 4

    MS Access stLinkCriteria Between Dates

    Hi,

    I have a filtered form that produces a set of employee names that are hyperlinks. When clicked, the EmployeeName hyperlink opens another form called Budgeted Time. I would like to filter the results of Budgeted Time to match the employee name and corresponding date range produced from the filters on the first form. The date fields are called txtstartdate and txtenddate. Many thanks for looking

    Code:
    Private Sub EmployeeName_Click()
    Dim stlinkcriteria As String
    stlinkcriteria = "[budgetdate] is between #" & [txtStartDate] & "# And #" & [txtEndDate] & "#" And "[EmployeeName] = '" & EmployeeName & "'"
    DoCmd.OpenForm "Budgeted Time", , , stlinkcriteria
    End Sub
  • MikeTheBike
    Recognized Expert Contributor
    • Jun 2007
    • 640

    #2
    Hi

    You do not indicate what the problem actualy is that you are having, but I would start by moding the code thus
    Code:
    stLinkCriteria = "[budgetdate] is between #" & Format([txtStartDate], "mm/dd/yy") & "# And #" & Format([txtEndDate], "mm/dd/yy") & "#" And "[EmployeeName] = '" & EmployeeName & "'"
    MTB

    p.s. this does not seem to be a hyperlink to me!?

    Comment

    • JpjVB
      New Member
      • Aug 2010
      • 4

      #3
      MTB,

      Thanks for getting back to me. Let me provide a little more detail. The field [EmployeeName] has its Is Hyperlink property set to Yes, and the above code is triggered on its On Click event procedure. The event opens a new form for that employee with a budget date within the range of the dates selected in txtstartdate and txtenddate in the original form's filter. The code produces a Run-Time Error '13': Type Mismatch.

      I hope this is helpful, thank you again for looking.

      Comment

      Working...