Re: How do I make a List box Prompt the user to Populated the fiel



On Tue, 12 Jun 2007 02:03:00 -0700, Arlene <Arlene@xxxxxxxxxxxxxxxxxxxxxxxxx>
wrote:

John,

Thank you for reply to my question. I would like the Prompt to be when they
try to leave the from

Open the form in design view; view its Properties. On the Events tab find the
BeforeUpdate event. Click the ... icon by that event and choose Code Builder.
Access will give you two lines:

Private Sub Form_BeforeUpdate(Cancel as Integer)

End Sub

You can put whatever code you like in between; you can use MsgBox to issue a
prompt, and you can set Cancel to True to prevent the user from closing the
form. For example:

Private Sub Form_Close(Cancel as Integer)
Dim iAns As Integer
If IsNull(Me!somecontrolname) Then
Cancel = True ' cancel the update of the record
iAns = MsgBox("Yadayada is blank! Fill it or click Cancel to erase:", _
vbOKCancel)
If iAns = vbOK Then
Me!Yadayada.SetFocus ' go to the required control
Else
Me.Undo ' erase the entire form so they can start over
End If
End If
End Sub


John W. Vinson [MVP]
.



Relevant Pages

  • Re: Compulsory Cells based on Condition
    ... Private Sub Workbook_BeforeSave(ByVal SaveAsUI _ ... As Boolean, Cancel As Boolean) ... am not sure how to prompt the user to do that and when to prompt them. ...
    (microsoft.public.excel.misc)
  • Re: Error Checking Question
    ... AfterUpdate is too late: the record has already been stored in the ... Private Sub Form_BeforeUpdate ... Dim iAns As Integer ... & " Cancel to erase the entire record and try over", ...
    (microsoft.public.access.gettingstarted)
  • Re: Flagging if record has been modified
    ... >How do I do it and in what form event would I place this check? ... Private Sub Form_BeforeUpdate ... Dim iAns As Integer ... Cancel = True ...
    (microsoft.public.access.forms)
  • Re: Open form code to enter a date in short date format
    ... > Dim strShowMonth As String ... > ' Prompt the user for the year to be shown initially. ... event procedure does not have a Cancel argument. ... Private Sub Form_Load ...
    (microsoft.public.access.formscoding)
  • Re: Message box help-probably easy
    ... "No check boxes were selected. ... Private Sub Form_BeforeUpdate ... Dim iAns As Integer ... Cancel = True ' you cancel the update in either case ...
    (microsoft.public.access.forms)

Loading