Results 1 to 6 of 6
  1. #1
    MFS is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235

    Inform user that all fields should be populated prior to saving


    Looking for a message box that informs the user that all fields must have data entered before they exit or save to the Database table.
    Also, when the user starts typing in any field the system automatically generates a new ID in the table. How can I keep this from happening until the user has completed all fields and a save button was pressed?
    A yes / no box should also appear asking the user if they would like to save prior to exiting the form or closing the DB. (Yes saves the data, No sends the user to Main form and nothing was saved to table.)

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    use a 'temp' data entry table/screen that a user enters the data into.
    If ALL the data fields are filled ,THEN run an append query to the main table, and THEN the ID is created.

  3. #3
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Or on BeforeUpdate on Form, test each field for data.

    If IsNull(me.field1) then
    msgbox "Field1 must have data"
    me.field1.Setfocus
    end
    else
    If IsNull(me.field2) then
    msgbox "Field2 must have data"
    me.field2.Setfocus
    end
    End IF
    End If

    Search MessageBox Yes No for examples on how to do those.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    The id is not saved until you move off the record or until any action is taken that saves the record begin created, so is that really an issue? If you were to cancel the record, the id is gone too. If it is an issue, I agree with the temp table solution. As for validating data entry, there are other options too, like having validation at the table field or form control level. However, this can be clunky and annoying since once data entry has been started in a control, it has to satisfy the requirement before you can leave it. So the BeforeUpdate is also what I'd use, however if you have a lot of controls to validate, the suggested code approach gets rather long. It also suffers from the aforementioned need to satisfy validation. This means that if you want to fill out other controls and come back to one when you've remembered what to put in, you can't.

    My preferred approach is to give each necessary control a tag like Reqd and loop through the form controls, looking for textboxes with that tag. Then I pass that control name to a little function that tests for Null and empty strings and if found, the function passes the label text of the control back to the sub. The name is added to a string list variable and the offenders are presented all at once. In order to get the label caption, it has to be attached to the textbox, otherwise you can only get the textbox name without resorting to more code to get the proper unattached label. Should you ever add a textbox to the form, all that's required to include it in the validation is the tag.
    Last edited by Micron; 08-12-2016 at 08:49 AM. Reason: clarification
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,706
    Micron's suggestion is elegant and your users will find it much to their satisfaction.

  6. #6
    MFS is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2009
    Location
    Ohio
    Posts
    235
    Thank You all for your support, I believe your posts will support my request, although I cannot try at this time.
    I will respond once I have a moment to return to this project

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

Similar Threads

  1. Automatically populated fields
    By lwinford in forum Forms
    Replies: 1
    Last Post: 04-30-2013, 09:24 AM
  2. Table fields populated from query
    By jcarstens in forum Access
    Replies: 1
    Last Post: 04-08-2012, 05:55 PM
  3. Replies: 5
    Last Post: 12-14-2011, 02:37 PM
  4. Issues with Auto populated fields
    By denise1005 in forum Queries
    Replies: 3
    Last Post: 03-17-2011, 10:50 AM
  5. Auto Populated Field not Saving to Table
    By EstesExpress in forum Forms
    Replies: 4
    Last Post: 10-09-2009, 03:33 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