I have an Access 2000 database that stores employees' time off requests which are submitted via an ASP page. The database consists of two tables ("tblUsers" and "tblRequests"
and a query ("qryTimeRemaining"
. The query is used to show users (on a different ASP page) time they've already entered, along with how many hours they have left (total hours available - all hours already requested).
I'd like to be able to prevent the user from adding a record to the database when it exceeds their available hours; however, I don't know how to combine the Requests table with the TimeRemaining query to accomplish this.
My current code for adding to the Requests table looks like this:
Set objConn = Server.CreateObject("ADODB.Connection"
ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("pto.mdb"
objConn.Open ConnectionString
sqlQuery = "SELECT * FROM requests"
Set objRS = Server.CreateObject("ADODB.Recordset"
objRS.Open sqlQuery, objConn, 1, 2
objRS.AddNew
objRS("Name"
=strSender
objRS("StartDate"
=strStart
objRS("EndDate"
=strEnd
objRS("Hours"
=strHours
objRS("Manager"
=strManager
objRS("SubmitDate"
=strDate
If strDetails="" Then
objRS("Details"
="None"
Else
objRS("Details"
=strDetails
End If
objRS.Update
objRS.Close
Set objRS = Nothing
I know I'd need another IF statement prior to the Update, but I'm a relative newbie to this and could really use some help getting "unstuck".
Thanks for anything you folks can offer.
Kyle
I'd like to be able to prevent the user from adding a record to the database when it exceeds their available hours; however, I don't know how to combine the Requests table with the TimeRemaining query to accomplish this.
My current code for adding to the Requests table looks like this:
Set objConn = Server.CreateObject("ADODB.Connection"
ConnectionString="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("pto.mdb"
objConn.Open ConnectionString
sqlQuery = "SELECT * FROM requests"
Set objRS = Server.CreateObject("ADODB.Recordset"
objRS.Open sqlQuery, objConn, 1, 2
objRS.AddNew
objRS("Name"
objRS("StartDate"
objRS("EndDate"
objRS("Hours"
objRS("Manager"
objRS("SubmitDate"
If strDetails="" Then
objRS("Details"
Else
objRS("Details"
End If
objRS.Update
objRS.Close
Set objRS = Nothing
I know I'd need another IF statement prior to the Update, but I'm a relative newbie to this and could really use some help getting "unstuck".
Thanks for anything you folks can offer.
Kyle