How to suppress that Access standard message?

X

xg

Right after my "Is not valid Section" message, there is another Access
standard message popup. How to suppress it?

Thanks.


Private Sub Sect_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("Course")
rst.FindFirst "[sem]&[sect] = '" & Me.Sem & Me.Sect & "'"
If rst.NoMatch Then
MsgBox Me.Sect & " Is not valid Section"
Cancel = True
Else
Me.Subj = rst![Subj]
Me.No = rst![No]
Me.Lt = rst![Lt]
End If
Set rst = Nothing

Exit_sect_BeforeUpdate:
Exit Sub
Err_sect_BeforeUpdate:
MsgBox Err.Description
Resume Exit_sect_BeforeUpdate

End Sub
 
D

Douglas J. Steele

Try

rst.FindFirst "[sem]= '" & Me.Sem & '" And [sect] = '" & Me.Sect & "'"
 
G

Guest

It's much faster creating a filter in the record set, then using he FindFirst
that can take a long time when alot of records involved

Try:

Private Sub Sect_BeforeUpdate(Cancel As Integer)
Dim rst As Recordset
Set rst = CurrentDb.OpenRecordset("Select * From Course Where [sem] = '"
& Me.Sem & "' And [sect] = '" & Me.Sect & "'")
If rst.Eof Then
MsgBox Me.Sect & " Is not valid Section"
Cancel = True
Else
Me.Subj = rst![Subj]
Me.No = rst![No]
Me.Lt = rst![Lt]
End If
Set rst = Nothing

Exit_sect_BeforeUpdate:
Exit Sub
Err_sect_BeforeUpdate:
MsgBox Err.Description
Resume Exit_sect_BeforeUpdate

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top