OhBother30
Technical User
I have a form with numerous records. Each record has an autonumber field as the key. When adding a new record I want to look at the previous record. If a particular field is null I do not want a new record to be added. I was trying the following code. I was able to get the message, but I don't know how to delete the record that the user was trying to add.
I had the code on "BeforeUpdate" for my autonumber and it didn't do anything. I changed it to "BeforeUpdate" on my second field. The problem is that an autonumber has already been asigned.
Any help would be appreciated.
Dim dbs As Database
Dim rst As Recordset
Dim CheckID As Integer
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("qryCheckoutRecord"
With rst
.MoveLast
End With
rst.Close
If IsNull(Me![InDate]) = True Then
MsgBox "Warning! This file is already checked out.", vbOKOnly, "Check Out Status"
Else
Exit Sub
End If
End Sub
I had the code on "BeforeUpdate" for my autonumber and it didn't do anything. I changed it to "BeforeUpdate" on my second field. The problem is that an autonumber has already been asigned.
Any help would be appreciated.
Dim dbs As Database
Dim rst As Recordset
Dim CheckID As Integer
Set dbs = CurrentDb()
Set rst = dbs.OpenRecordset("qryCheckoutRecord"
With rst
.MoveLast
End With
rst.Close
If IsNull(Me![InDate]) = True Then
MsgBox "Warning! This file is already checked out.", vbOKOnly, "Check Out Status"
Else
Exit Sub
End If
End Sub