troubleshooting Question

keep getting 3421 errors querydef  parameters on date field!

Avatar of Peter Groves
Peter Groves asked on
Microsoft AccessVBA
21 Comments1 Solution136 ViewsLast Modified:
Need to get parameters passed to query but keep getting 3421 error type mismatch!

I have a form that I use to select a start date called STARTDATE an it is formatted as short date which gives todays date as  2018-12-11 09:19:23
In my query I have a criteria that I put as  >[STARTDATE2]   and its format is as DATE/TIME. No matter what combination I try I still get type conversion errors!

Private Sub execute_RAP_Click()
    Dim db              As DAO.Database
    Dim qdf             As DAO.QueryDef
    Dim prm             As DAO.Parameter
    Dim rs              As DAO.Recordset
 Dim results As String
 
    Set db = CurrentDb
    Set qdf = db.QueryDefs("ECH_update1210")
 
    qdf.parameters([STARTDATE2]) = Me.STARTDATE
   
    Set rs = qdf.OpenRecordset
 
    'Work with the recordset
 
 
        Do Until rs.EOF
            results = results & rs.Fields("net_num") & "; "
rs.movenext
        Loop

     'Cleanup after ourselves
    Set qdf = Nothing
    Set db = Nothing
   


Set db = Nothing
Set rs = Nothing

End Sub

I've tried several combinations with CDATE() and FORMAT with same results!
Pete
ASKER CERTIFIED SOLUTION
aikimark
Get vaccinated; Social distance; Wear a mask
Join our community to see this answer!
Unlock 1 Answer and 21 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 21 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros