Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2010
    Posts
    15

    Unanswered: Data type mismatch in criteria expression. (Error 3464)

    I can not figure out how to get the my command to get to my form without having a data type mismatch heres a sample of the code. PLEASE HELP.

    Private Sub Command0_Click()

    On Error GoTo Err_Command0_Click

    Dim stDocName As String
    Dim stLinkCriteria As String
    Dim stLabel As String
    Dim iColor As Long
    Select Case Frame31
    Case 1
    stLabel = "All Backflow Tester Information"
    iColor = 255
    Case 2
    stLinkCriteria = "([CalExpires]>Now()) And ([Tester_Info.TNRCC_Reg_Date]<Now())"
    stLabel = "Current Backflow Tester Information"
    iColor = 32768
    Case 3
    stLinkCriteria = "([CalExpires]<Now()) Or ([Tester_Info.TNRCC_Reg_Date]<Now())"
    stLabel = "Expired Backflow Tester Information"
    iColor = 0
    End Select
    stDocName = "Tester Information"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Forms![Tester Information].Label73.Caption = stLabel
    Forms![Tester Information].Section(1).BackColor = iColor
    Forms![Tester Information].Detail.BackColor = iColor

    Exit_Command0_Click:
    Exit Sub

    Err_Command0_Click:
    MsgBox Err.Description
    Resume Exit_Command0_Click

    End Sub

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    We can't help you very easily without knowing what line the error is occuring on.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jan 2010
    Posts
    15
    the data mismatch seems to be occuring with the dim stLinkCriteria As String
    and the second case which is stLinkCriteria = "([CalExpires]>Now()) And ([Tester_Info.TNRCC_Reg_Date]<Now())"

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Try dim it as a variant

    also, when you're working with dates, you often need to use the # within your expression to use criteria with a date value. (ie. = #" & me!MyDateField & "#" or = #" & myDateVariable & "#" or = #" & Date() & "#".

    You may also want to dim a date type variable and then set that variable = date() or now() and then use that variable (instead of Date() or Now()) in your expression.
    Last edited by pkstormy; 01-22-10 at 19:47.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Quote Originally Posted by trey3143 View Post
    the data mismatch seems to be occuring with the dim stLinkCriteria As String
    and the second case which is stLinkCriteria = "([CalExpires]>Now()) And ([Tester_Info.TNRCC_Reg_Date]<Now())"
    Are you guessing, or are those definitely the lines that are throwing an error?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  6. #6
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    I'm guessing he's guessing.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  7. #7
    Join Date
    Jan 2010
    Posts
    15
    i fixed it by changing the parameters of the filter

  8. #8
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Thanks for posting back on the solution!!
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •