Results 1 to 3 of 3
  1. #1
    Rico is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    Perth Australia
    Posts
    9

    I am having trouble with the Date/Time data type

    Set InRS = mydb.OpenRecordset("Select * from DocAndPodTB")
    If InRS.EOF Then
    Else
    Do Until InRS.EOF
    Set OutRS = mydb.OpenRecordset("Select * from DocTimesTB where AppointmentTime = '" & InRS!AppointmentTime & "'")
    If OutRS.EOF Then
    Else
    OutRS.Edit


    OutRS!TimeUsed = "Yes"
    OutRS.Update
    OutRS.Close
    End If
    Set OutRS = Nothing
    InRS.MoveNext
    Loop
    End If
    InRS.Close
    Set InRS = Nothing
    DocAndPodTB has AppointmentTime as Date/Time datatype
    DocTimesTB has AppointmentTime as Date/Time datatype

    If I hold the mouse over InRS!AppointmentTime it shows 11:00:00 AM
    But the Set outRS = mydb.openRecordset line fails with;
    Run-Time error 3464
    Data type mismatch in criteria expression
    Any help would be greatly appreciated.
    Thanks, Roco

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    10,750
    Must delimit date/times with octothorpe (#) if the field is date/time. You're passing it as a string, so we'd have to know what the field data type is in the table if this doesn't fix the error:

    = #" & InRS!AppointmentTime & "#")

    That error message is one of the better/clearer ones IMO - quite simply the data type you're trying to use is incorrect for the field.

    Please post more than a couple of lines of code within code tags (use # button on posting toolbar) to retain indentation and make it easier to read.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Rico is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    Perth Australia
    Posts
    9
    Thanks to Micron for the quick reply, it fixed my problem straight away.
    I have noted your comment:
    Please post more than a couple of lines of code within code tags (use # button on posting toolbar) to retain indentation and make it easier to read.
    I will in future. Rico

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 10-30-2017, 02:33 PM
  2. Replies: 3
    Last Post: 07-06-2016, 09:37 PM
  3. Replies: 11
    Last Post: 07-20-2014, 06:22 PM
  4. Replies: 1
    Last Post: 03-13-2014, 07:23 PM
  5. Replies: 1
    Last Post: 08-07-2011, 07:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums