Results 1 to 4 of 4
  1. #1
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169

    Null field message

    I almost have this but not quite. I have a button that a user can click to take them to a detailed form but I don't want them to be able to go to the detailed form unless they populate something into a field called [Question]. The code I have below is working except that after displaying the message, I would like the user to be taken back to the [Question] field on the form. What am I missing? Thanks for any help.
    Code:
    Private Sub Command206_Click()
    On Error GoTo Err_Command206_Click
     
        Dim strMsg As String, strTitle As String
        Dim intStyle As Integer
    If IsNull(Me!Question) Or Me!Question = "" Then
        strMsg = "You must enter something in the Question field before going to the detail screen."
        strTitle = "Question Text Missing"
        intStyle = vbOKOnly
        MsgBox strMsg, intStyle, strTitle
     
    End If  
     
        RunCommand acCmdSaveRecord
        Dim stDocName As String
        Dim stLinkCriteria As String
        stDocName = "frmMain"
     
        stLinkCriteria = "[QuestID]=" & Me![QuestID]
        DoCmd.OpenForm stDocName, , , stLinkCriteria
        DoCmd.Close acForm, "frmMainTEST"
    Exit_Command206_Click:
        Exit Sub
    Err_Command206_Click:
        MsgBox Err.Description
        Resume Exit_Command206_Click
    End Sub


  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Me.Question.SetFocus

    and probably

    Exit Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jpkeller55 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    169

    Thumbs up

    That did it...I needed the Exit Sub as I wasn't sure how to get out of the Sub at that point. Thanks for your help...I think I am learning with your help!

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. error message
    By ngeng4 in forum Forms
    Replies: 85
    Last Post: 03-25-2010, 06:47 AM
  2. If Form Field is not null then...
    By cotri in forum Forms
    Replies: 5
    Last Post: 01-12-2010, 11:08 AM
  3. Error message and How do I find the "value Field" ?
    By createdwithfire in forum Forms
    Replies: 1
    Last Post: 11-05-2009, 12:26 PM
  4. message box help
    By shaz10010 in forum Forms
    Replies: 1
    Last Post: 04-17-2009, 09:11 AM
  5. Message in Field
    By supatsiri in forum Reports
    Replies: 0
    Last Post: 03-09-2009, 01:59 AM

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