I'm new to writing functions, and can really use your help before this project is pulled from me!!
tables: projects, changeorders
Changeorder table fields: projectID, taskName, due, complete, billed
problem: have to be able to pull ONE of the 3 dates (due, complete, billed) for a specific task. Tasks vary from project to project, hence I am not creating a field for each task.
desire: drop that one resulting date in a column of a query (or directly in a report)
What I have come up with is creating a function that brings in the taskName and the type of date needed (such as due), returning the resulting date. Here is what I have for code so far, but it's not working:
Public Function GetRS(strTask As String, strDateType As String) As Date
'Creates recordset for reporting based on user criteria
Dim rs As Recordset
Dim strSQL As String
rs.Filter = strTask
strSQL = "SELECT tblChangeOrder." & strDateType & " FROM tblChangeOrder"
Set db = CurrentDb()
Set rs = db.openrecordset(sqlString, dbOpenSnapshot)
return GetRS
rs.Close
Set rs = Nothing
Set db = Nothing
End Function
tables: projects, changeorders
Changeorder table fields: projectID, taskName, due, complete, billed
problem: have to be able to pull ONE of the 3 dates (due, complete, billed) for a specific task. Tasks vary from project to project, hence I am not creating a field for each task.
desire: drop that one resulting date in a column of a query (or directly in a report)
What I have come up with is creating a function that brings in the taskName and the type of date needed (such as due), returning the resulting date. Here is what I have for code so far, but it's not working:
Public Function GetRS(strTask As String, strDateType As String) As Date
'Creates recordset for reporting based on user criteria
Dim rs As Recordset
Dim strSQL As String
rs.Filter = strTask
strSQL = "SELECT tblChangeOrder." & strDateType & " FROM tblChangeOrder"
Set db = CurrentDb()
Set rs = db.openrecordset(sqlString, dbOpenSnapshot)
return GetRS
rs.Close
Set rs = Nothing
Set db = Nothing
End Function