Hello,
I've been trying to debug for days with no luck. I am trying to write a conditional statement to evaluate "if my text is already in the field, then exit sub, if not, then add".
Below is my code. Everything I'd tried doesn't seem to work. I've even tried to do DLookup to see if it returned NULL.
Anything will be helpful!
I've been trying to debug for days with no luck. I am trying to write a conditional statement to evaluate "if my text is already in the field, then exit sub, if not, then add".
Below is my code. Everything I'd tried doesn't seem to work. I've even tried to do DLookup to see if it returned NULL.
Anything will be helpful!
Code:
Dim db As Database
Dim rs As DAO.Recordset
Set db = CurrentDb()
Set rs = db.OpenRecordset("Approvals")
Count_of_Text = DCount("[ApprovalID]", "Approvals", Me.ApprovalID)
If Count_of_Text > 0 Then 'Check to see if record already exists
MsgBox "Approval already in database."
Exit Sub
Else
With rs 'Add record information
.AddNew
.Fields("ApprovalID") = Me.ApprovalID
.Update
.Close
End With