I am attempting to create a text field after update validation to check to see if a study id already exists. If it does, a warning message will appear informing the user that such a study already exist. Below is the code I have, however, upon execution, I receive the error,
Run-time error '3061':
Too few parameters. Expected 2.
Run-time error '3061':
Too few parameters. Expected 2.
Code:
Private Sub Add_Study_ID_AfterUpdate()
Dim db As Database
Dim rs As DAO.Recordset
Dim sSQL As String
'Check that all the relevent controls meet the criteria
If Nz(Me.Add_Study_ID, 0) > 0 And Len(Nz(Me.Add_Study_ID, "")) > 0 Then
sSQL = "SELECT Study_ID FROM dbo_Setup WHERE ScheduleNum = Me.Add_Study_ID "
'Check the database
Set db = CurrentDb
[COLOR="red"]Set rs = db.OpenRecordset(sSQL, dbOpenSnapshot)[/COLOR]
If rs.AbsolutePosition > 0 Then
MsgBox "The Study Short Title enterted already exists."
End If
End If
rs.Close
Set rs = Nothing
Set db = Nothing