Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169

    forcing the user to choose a value


    friends,


    I have a subform. When the last field of a record is completed, shows a message to the user and moves the focus to the first field of the next record, this field has a list box. How do I force the user chooses a value. Do not leave the field without assigning a value.


    Thank you.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Not Is Null and <> 0
    Try this in the Validation Rule property of the control.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Be careful. If a user is forced to choose a value, how do you ever exit the form?

    I would use the form Before Update event to validate the record. Check if there is a value, if not ask if you really want to save this record. If yes, tell them they need to enter a value from the list box. If not, cancel the new record.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by ssanfu View Post
    Be careful. If a user is forced to choose a value, how do you ever exit the form?

    I would use the form Before Update event to validate the record. Check if there is a value, if not ask if you really want to save this record. If yes, tell them they need to enter a value from the list box. If not, cancel the new record.
    I think this is a good point, well made.
    Last edited by Bob Fitz; 04-15-2012 at 04:24 PM. Reason: typo
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    Friends thank you for help.


    In the field, I tried the event before updating:


    Private Sub Passo_BeforeUpdate(Cancel As Integer)


    If IsNull(Me.Passo) Then
    MsgBox "Por favor, indique o próximo passo"
    Me.Passo.SetFocus
    Else
    Exit Sub


    End If


    End Sub


    But it did not work.

  6. #6
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Try:

    Code:
    Private Sub Passo_BeforeUpdate(Cancel As Integer)
       If IsNull(Me.Passo) Then
         MsgBox "Por favor, indique o próximo passo"
         Cancel = TRUE
         Me.Passo.SetFocus
      End If
    
    End Sub
    Don't need the "Else" and "Exit sub" lines.

  7. #7
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    ssanfu Thank you.

    I tried as you posted, but did not work.

  8. #8
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    OK, what do you mean by "...but did not work." ??

    Is this in the FORM before update event or the CONTROL before update event??

  9. #9
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    I tried this:


    Private Sub Passo_BeforeUpdate(Cancel As Integer)
    If IsNull(Me.Passo) Then
    MsgBox "Por favor, indique o próximo passo"
    Cancel = True
    Me.Passo.SetFocus
    End If


    End Sub

    Thank You.




  10. #10
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Is "Passo" a control or a form???

    What is not "working"??

  11. #11
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    "Passo" is the name of the field where I'm trying not to stay empty.


    But no effect.

  12. #12
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You should be using the FORM Before Update event

  13. #13
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    In the event before updating the form I put:


    Private Sub Form_BeforeUpdate(Cancel As Integer)
    If IsNull(Me.Passo) Then
    MsgBox "Por favor, indique o próximo passo"
    Cancel = True
    Me.Passo.SetFocus
    End If
    End Sub


    Had no effect.

  14. #14
    Kirsti is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Jan 2012
    Location
    New Zealand
    Posts
    172
    Hi there,

    Just an idea - but the way I got around this issue in my form was by:

    1. "Limit To List" = Yes in the Data Properties of the combo box in the form

    And then,

    In the Table properties set "Required" to "Yes" and set your Validation Text there.

    Kirsti

  15. #15
    fabiobarreto10 is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    169
    Kirsti, thank you for help.
    I did as you said, but did not work. Had no effect.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Forcing users to use DB via system.mdw
    By simon955 in forum Programming
    Replies: 1
    Last Post: 01-30-2012, 02:15 PM
  2. Forcing a Report to Expand Horizontally
    By Rawb in forum Reports
    Replies: 3
    Last Post: 06-23-2010, 08:36 AM
  3. Forcing text to upper case
    By barrettp in forum Forms
    Replies: 10
    Last Post: 06-01-2010, 09:44 AM
  4. Msg-box - choose teamnumber
    By carstenhdk in forum Reports
    Replies: 5
    Last Post: 05-31-2010, 01:32 PM
  5. Replies: 3
    Last Post: 10-15-2009, 12:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums