C
Chad
Hello, I have some code in my forms unload event and this code brings up an
Msgbox if there are null fields in my records shows me what the ID numbers
are and closes the form and opens frmSwitchboard. Right now it has Just the
"OK" button to do this but I want to add a "cancel" button so instead of
closing the form and opening the frmSwitchboard it keeps the current form
"frmMainDB" open. How and what would I add to the code? Thanks!!!!
Private Sub Form_Unload(Cancel As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intX As Integer
Dim strIDs As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("qryFindNullRecords", dbOpenSnapshot)
If rs.RecordCount > 0 Then
With rs
..MoveLast
..MoveFirst
intX = .RecordCount
Do Until .EOF
strIDs = strIDs & .Fields("ID") & vbCrLf
..MoveNext
Loop
End With
MsgBox "There is information missing in " & intX & " record(s) that hasn't
been entered within todays" & vbCrLf _
& "records or yesterdays records. The record ID's are" & vbCrLf & vbCrLf _
& strIDs & vbCrLf _
& "Please follow up on missing data!", vbOKOnly + vbExclamation, "Missing
Information"
End If
rs.Close
Set rs = Nothing
Set db = Nothing
Forms![frmSwitchboard].Visible = True
End Sub
Msgbox if there are null fields in my records shows me what the ID numbers
are and closes the form and opens frmSwitchboard. Right now it has Just the
"OK" button to do this but I want to add a "cancel" button so instead of
closing the form and opening the frmSwitchboard it keeps the current form
"frmMainDB" open. How and what would I add to the code? Thanks!!!!
Private Sub Form_Unload(Cancel As Integer)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim intX As Integer
Dim strIDs As String
Set db = CurrentDb()
Set rs = db.OpenRecordset("qryFindNullRecords", dbOpenSnapshot)
If rs.RecordCount > 0 Then
With rs
..MoveLast
..MoveFirst
intX = .RecordCount
Do Until .EOF
strIDs = strIDs & .Fields("ID") & vbCrLf
..MoveNext
Loop
End With
MsgBox "There is information missing in " & intX & " record(s) that hasn't
been entered within todays" & vbCrLf _
& "records or yesterdays records. The record ID's are" & vbCrLf & vbCrLf _
& strIDs & vbCrLf _
& "Please follow up on missing data!", vbOKOnly + vbExclamation, "Missing
Information"
End If
rs.Close
Set rs = Nothing
Set db = Nothing
Forms![frmSwitchboard].Visible = True
End Sub