The label name is lblClose
Here goes..
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
'Disable Pg-up and Pg-down keys
Select Case KeyCode
Case 33, 34, 18
KeyCode = 0
Case Else
End Select
End Sub
*************************************
Private Sub Form_Load()
'Turn the MouseWheel Off
Dim blRet As Boolean
blRet = MouseWheelOFF
End Sub
**************************
Private Sub Form_Open(Cancel As Integer)
Me.RecordSource = Forms!frmContacts.RecordSource
Dim rs As DAO.Recordset
If Not IsNull(Me.OpenArgs) Then
Set rs = Me.RecordsetClone
rs.FindFirst "[ContactID]=" & Me.OpenArgs
If rs.NoMatch Then
Else
Me.Bookmark = rs.Bookmark
End If
End If
End Sub
**********************************
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim Response As Integer
If Not IsNull(Me!Listing) And IsNull(Me!ContactTypeID) Then
Response = MsgBox("You failed to enter required data." & vbCrLf & _
"Do you want to continue editing the record?", vbExclamation
+ vbYesNo, _
"Missing Required Data")
If Response = vbNo Then
Me.Undo
Me.Requery
Else
Me!ContactTypeID.SetFocus
End If
End If
End Sub
*****************************************
Private Sub Form_Close()
Forms!frmContacts.Requery
Forms!frmContacts!lstContacts.Requery
Forms!frmContacts!lstContacts.Selected(0) = True
End Sub
'***************************************
Private Sub lblClose_Click()
Dim Response As Integer
If Not IsNull(Me!Listing) And IsNull(Me!ContactTypeID) Then
Response = MsgBox("You failed to enter required data." & vbCrLf & _
"Do you want to continue editing the record?",
vbExclamation + vbYesNo, _
"Missing Required Data")
If Response = vbNo Then
Me.Undo
Call GlobalClose
Else
Me!ContactTypeID.SetFocus
End If
Else
Call GlobalClose
End If
End Sub
***************************************
Private Sub lblNew_Click()
DoCmd.GoToRecord , , acNewRec
Me!Listing.SetFocus
End Sub
Private Sub PhoneNumber_Click()
Me!PhoneNumber.SelStart = 0
End Sub
***********************************************************************
Private Sub ContactTypeID_NotInList(NewData As String, Response As
Integer)
Dim strSql As String
Dim i As Integer
Dim Msg As String
If Response = acDataErrContinue Then Exit Sub
Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Please make a selection that is in the list."
i = MsgBox(Msg, vbInformation + vbOKOnly, "Not In List")
Response = acDataErrContinue
End Sub
Ken Snell said:
The code looks fine. Thus, there must be some other stuff going on in
the code. Post all the code that is in the form's module (if not 1000s
of lines long); what is the name of the label control?
--
Ken Snell
<MS ACCESS MVP>
I'm replacing my command buttons with labels for cosmetic reasons.
The following validation code works for the command button but not for
the
label. When I click the label form closes no matter which MsgBox button
I click.
The following code was copied and pasted from the command button to the
label.
Dim Response As Integer
If Not IsNull(Me!Listing) And IsNull(Me!ContactTypeID) Then
Response = MsgBox("You failed to enter required data." & vbCrLf & _
"Do you want to continue editing the record?",
vbExclamation + vbYesNo, _
"Missing Required Data")
If Response = vbNo Then
Me.Undo
Call GlobalClose
Else
Me!ContactTypeID.SetFocus
End If
Else
Call GlobalClose
End If
Any help will be appreciated.
James