I ran a query with the ID#, TaskName, DueDate, (using the same sql as my function) - here's the results:
txtSiteID Document dtmDueDate
SA13 NIER (empty)
TA01 NIER 3/5/2003
SA12 NIER 3/5/2003
TA18 NIER 3/5/2003
I run the same query using my function:
txtSiteID Document getRS function
SA13 NIER 12:00:00 AM
TA01 NIER 12:00:00 AM
SA12 NIER 12:00:00 AM
TA18 NIER 12:00:00 AM
Help please, why is my function returning a time when it should be the same results as dtmDueDate (date)? I need to use a function to build a query that will pull a the due date for a specific document. I will be using the function multiple times in the query, asking for another date, like the rec'd date, or a different document. I'll then use this query for a report. The reason I need to do this is that I have to produce a report with fields from multiple tables, and managements only wants specific documents and dates in thier order, not just putting a subreport in the report.
Public Function GetRS(strTask As String, strDateType As String) As String
'Creates recordset for reporting based on user criteria
Dim rst As ADODB.Recordset
Dim strSQL As String
'create sql string selecting records related to specific task
strSQL = "SELECT tblDocumentDetail.txtSiteID, tblDocumentDetail.txtDocumentName, "
strSQL = strSQL & "tblDocumentDetail." & strDateType
strSQL = strSQL & " FROM tblDocumentDetail "
strSQL = strSQL & "WHERE (((tblDocumentDetail.txtDocumentName)= '" & strTask & "'));"
'Declare and instantiate a recordset
Set rst = New ADODB.Recordset
'Establish the connection, cursor type,
'and lock type, and open the recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenStatic
rst.LockType = adLockOptimistic
rst.Source = strSQL
rst.Open
rst.MoveFirst
rst.Close
Set rst = Nothing
End Function