I've been messing around attempting to get a field in a form to notify the person entering information if a record already exists, and allow a quick link to edit said existing record. I'm having very little luck making everything work the way I believe it should. I have virtually no understanding of VB, so I've been getting advice along the way and inserting what I believe to be the right values into each section.
I'm posting a screen shot of the form I'm using and the code associated with it. Along with the error when executed/the highlighting after that.
I don't know enough to know why this isn't working, and have attempted to stumble upon a solution to no avail. I'm hoping it's something really obvious to you gurus. Thank you anyone that gives this some thought.
I'm posting a screen shot of the form I'm using and the code associated with it. Along with the error when executed/the highlighting after that.



Code:
Private Sub YC_TAG_AfterUpdate()
If DCount("YC_TAG", "Assets", _
"YC_TAG = " & Me.YC_TAG) = 0 Then
DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
Else
If MsgBox("This asset already exists in the database. " & _
"Would you like to edit that record?", vbExclamation + vbYesNo) =vbYes
Then
DoCmd.SearchForRecord ([acDataForm = Me.Name, "YC_TAG", Me.Name = acFirst])
End If
End If
End Sub
I don't know enough to know why this isn't working, and have attempted to stumble upon a solution to no avail. I'm hoping it's something really obvious to you gurus. Thank you anyone that gives this some thought.