Results 1 to 5 of 5
  1. #1
    mfmathes is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2011
    Location
    Virginia
    Posts
    5

    Need to customize error statements in form

    I created a database for obtaining customer information at a trade show. The entry form is set to Pop up. Entry in data fields is required. I set a macro at the end of the entry form, "New Record Macro" to save the record and then to GoToRecord to create a new blank form for the next person to fill in. When a field is left blank, an error screen pops up using the actual name of the field left blank. Then a Macro Single Step error screen pops up. I need to replace these pop ups with customized directions. I'd like to completely eliminate the Macro Single Step error. I have no experience in Visual Basic. I am using Access 2010.

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    if you're not using VB you're not likely going to get the result you want

    if ALL of the fields are required for a record to be valid in your 'go to new record' ON CLICK event you could have something like


    Code:
    if isnull(field1) or isnull(field2) then
        msgbox "ERROR:  all fields must be populated before creating a new record, it ESC twice to cancel record or fill in blank fields"
    else
       ' do whatever your current procedure does
    endif

  3. #3
    mfmathes is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Location
    Virginia
    Posts
    5
    I converted my macro to VB and attempted to modify code to incorporate recommendations. I think something must be wrong because the error statements remain Access default.

    I copied and pasted my code. Any suggestions? Thank you.

    '------------------------------------------------------------
    ' New_Record_Macro
    '
    '------------------------------------------------------------
    Function New_Record_Macro()
    On Error GoTo New_Record_Macro_Err


    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.GoToRecord acForm, "Entry", acNewRec




    New_Record_Macro_Exit:
    Exit Function


    If IsNull(FirstName) Or IsNull(LastName) Or IsNull(Address1) Or IsNull(City) Or IsNull(State) Or IsNull(Zip) Or IsNull(Phone) Or IsNull(email) Then
    MsgBox "ERROR: All starred fields must be completed. Hit ESC twice to cancel record or fill in all starred fields"
    Else
    Resume New_Record_Macro_Exit
    End If


    End Function

  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
    You want that If block before the save line. You might also consider:

    http://www.baldyweb.com/BeforeUpdate.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    you want this in the ON CLICK event of your button


    Code:
    If IsNull(FirstName) Or IsNull(LastName) Or IsNull(Address1) Or  IsNull(City) Or IsNull(State) Or IsNull(Zip) Or IsNull(Phone) Or  IsNull(email) Then
              MsgBox "ERROR: All starred fields must be completed. Hit ESC twice to cancel record or fill in all starred fields"
    Else
          DoCmd.RunCommand acCmdSaveRecord
              DoCmd.GoToRecord acForm, "Entry", acNewRec
    End If

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

Similar Threads

  1. Customize Report X of Y
    By sachinmalik007 in forum Access
    Replies: 3
    Last Post: 05-04-2012, 08:45 AM
  2. Replies: 4
    Last Post: 06-22-2011, 10:53 AM
  3. Nested If Statements Using Or (Logic Error)
    By IFA Stamford in forum Access
    Replies: 7
    Last Post: 12-30-2010, 08:53 AM
  4. Customize button "goto last record"
    By bertenbert in forum Forms
    Replies: 1
    Last Post: 12-30-2010, 08:38 AM
  5. Customize Message Box On Command
    By jpkeller55 in forum Access
    Replies: 3
    Last Post: 09-08-2010, 09:18 PM

Tags for this Thread

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