R
Richard Hollenbeck
I want to test for the existance of an activity discription
within a college course for a gradebook program before adding a
new activity to that course. This should prevent duplicate
activities in that course. In other words, if the activity does
not exist the program will continue but if it does exist it will
stop the user from adding that activity again. But if it does
not exist I get an error saying that no record exists. I don't
need that error. If the user types the name of an already
existing activity name, I want to alert the user that this
activity already exists. Otherwise they can continue. How do I
get rid of the error? Here's the beginning of my code with
superfluous details omitted:
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
strSQL = "SELECT courses.courseCode,
activities.activityDescription FROM (courses INNER JOIN groups ON
courses.courseCode = groups.courseCode) INNER JOIN activities ON
groups.groupID = activities.groupID WHERE (((courses.courseCode)=
'" & [Forms]![frmSelectCourse]![cboSelectCourse] & "') AND
((activities.activityDescription)= '" & txtAD & "'))"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveLast
rs.MoveFirst
Then do one thing if the rs.RecordCount <1 and another thing if
the rs.RecordCount >0.
I just want to get rid of the "No Record" error, because it's not
an error in this case. Any ideas?
Thanks.
Rich Hollenbeck
within a college course for a gradebook program before adding a
new activity to that course. This should prevent duplicate
activities in that course. In other words, if the activity does
not exist the program will continue but if it does exist it will
stop the user from adding that activity again. But if it does
not exist I get an error saying that no record exists. I don't
need that error. If the user types the name of an already
existing activity name, I want to alert the user that this
activity already exists. Otherwise they can continue. How do I
get rid of the error? Here's the beginning of my code with
superfluous details omitted:
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
strSQL = "SELECT courses.courseCode,
activities.activityDescription FROM (courses INNER JOIN groups ON
courses.courseCode = groups.courseCode) INNER JOIN activities ON
groups.groupID = activities.groupID WHERE (((courses.courseCode)=
'" & [Forms]![frmSelectCourse]![cboSelectCourse] & "') AND
((activities.activityDescription)= '" & txtAD & "'))"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
rs.MoveLast
rs.MoveFirst
Then do one thing if the rs.RecordCount <1 and another thing if
the rs.RecordCount >0.
I just want to get rid of the "No Record" error, because it's not
an error in this case. Any ideas?
Thanks.
Rich Hollenbeck