Hi All.
I am creating a new equipment library database. The user will log when they are taking a piece of equipment from the library using a booking out form called 'PoolBookings'. This saves a record of the equipment's asset number, their name and department, and the current date and time. It does so in a table called 'PoolBookings'.
When the user returns the equipment, they then open up the returns form called 'PoolReturns'. On this form they enter the same information as the booking out form. The only difference being, that the equipment asset number text box for them to type in to is now unbound and the textbox is called 'CodeNoReturning'. Once they hit the complete button on the form, I want to look through all records in the 'PoolBookings' table and find the last record with the same asset number that is in the 'CodeNoReturning' box, that also has a null value in the DateIn field.
Below is an example of the fields in the table and also a view of the Returns form.
The code currently behind the Complete Returning button is...
This works OK at the moment, however I want to add an AND to the strSql to help find records with the same CodeNo, but also have not already been returned, so the DateIn value should be null. When I add AND DateIn Is Null to the end of the StrSql I get a message saying ' Run-Time Error 424 'Object Required' '.
I can't figure out how to get around this.
Would anybody know why this is happening?
I think once I get around this I will be OK with the rest of the process of updating the records data.
Thanks in advance
I am creating a new equipment library database. The user will log when they are taking a piece of equipment from the library using a booking out form called 'PoolBookings'. This saves a record of the equipment's asset number, their name and department, and the current date and time. It does so in a table called 'PoolBookings'.
When the user returns the equipment, they then open up the returns form called 'PoolReturns'. On this form they enter the same information as the booking out form. The only difference being, that the equipment asset number text box for them to type in to is now unbound and the textbox is called 'CodeNoReturning'. Once they hit the complete button on the form, I want to look through all records in the 'PoolBookings' table and find the last record with the same asset number that is in the 'CodeNoReturning' box, that also has a null value in the DateIn field.
Below is an example of the fields in the table and also a view of the Returns form.
The code currently behind the Complete Returning button is...
Code:
Private Sub CommandCompleteReturning_Click()
Dim db As DAO.Database
Dim REC As Recordset
Dim strSql As String
Dim TotalRecords As Integer
Dim n As Integer
strSql = "SELECT * FROM PoolBookings WHERE [CodeNo] = " & "'" & Me.CodeNoReturning & "'"
Set db = CurrentDb()
Set REC = db.OpenRecordset(strSql, dbOpenDynaset)
REC.MoveLast
TotalRecords = REC.RecordCount
REC.Close
Message = "MediPool has found " & TotalRecords & _
" records in the Pool Bookings table" _
& Chr(10) & "Do you wish to continue?"
Title = "MediPool Code Finder"
Response = MsgBox(Message, vbOKCancel, Title)
End Sub
This works OK at the moment, however I want to add an AND to the strSql to help find records with the same CodeNo, but also have not already been returned, so the DateIn value should be null. When I add AND DateIn Is Null to the end of the StrSql I get a message saying ' Run-Time Error 424 'Object Required' '.
I can't figure out how to get around this.
Would anybody know why this is happening?
I think once I get around this I will be OK with the rest of the process of updating the records data.
Thanks in advance