Pardon the code below. I am a VBA novice. I am looking to upon clicking a form button, inform customers that they must make another library selection if the item they have chosen is checked out. I determine something is checked out if the "Check In Date" for the most recent date in the "1Transaction" table is NULL. Note for every check in and check out, a new record is created in the 1Transaction table and every record (whether check in or check out) will have the check out date info. So the logic, take the most recent date for the lease (book) number and if there is no return date then it is still checked out. The code below is meant to make the references and return a message box in VBA but I am stuck. I understand logically what I require but I know my VBA syntax is very off. Thanks.
Private Sub Check_Out()
If [1Transactions].[Asset].Value = Me.Lease_Num
And DMax([Tables]![1Transactions].[Check Out Date])
And [Tables]![1Transactions].[Check In Date] = NULL
Then MsgBox "The requested documents are currently checked out"
End If
DoCmd.OpenForm "Check In"
End Sub
Note:
- 1Transactions = Table holding all check in/out data
- Me.Lease_Num = value pulled from combo box that user fills out to provide "lease number" (book code) they are interested in checking out.