Results 1 to 7 of 7
  1. #1
    Rosier75 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    18

    Immediately update table with form?

    I have a database that contains data for multiple users. I have created forms that allow users to search the database based on specific criteria and update records in the associated table (via a command button) if need be. Is there a way to have records in a table update immediately after making updates in the form? I currently accomplish my updates by using a different append/update queries. I'm thinking there has to be an easier way.

    Can anyone help with this?



    Thanks

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    By simple way is by using Access as it was intended to be used, with Bound Forms! When a Form is Bound, the Record is committed to the Table, automatically, as soon as the user moves to another Record, closes the Form or closes Access itself.

    Don't know why you're apparently using Unbound Forms, here. The usual justification for this is the belief that Unbound Forms are necessary in order to do data validation before "committing" data to a Table, and this is simply not true!

    Any "checks" you need to do before saving the data can be done using the Form_BeforeUpdate event of a bound form and Cancel = True to stop the saving of the record until missing/erroneous data is dealt with!

    A big part of the reason to use Access for database development is the speed with which it can be created, using Bound Forms. Several developers I know, experienced in both Visual Basic database development and Access development, estimate that development using Unbound Forms by experienced developers takes two to three times as long as it does when using Access and Bound Forms.

    If you insist on using unbound forms, you'd be far better off using a straight VB or C++ front end with a SQL Server or Oracle back end.
    • You can create an EXE file which gives total protection to your code/design
    • You can distribute the db to PCs without a copy of Access being on board
    • Your data security is far, far better than anything you can do in Access


    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Rosier75 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2011
    Posts
    18
    Thanks for the quick reply. The form I am referencing is bound to a specific table. It is true that the when the form fields are updated, the table itself will be updated when the user cycles to an additional record or closes the form. What I am trying to determine is if there is a way to automatically and/or immediately commit the value/text inputted in the form field to the bound table without moving to the next record? This step is important to the overall use and intent of the database.

    Thanks

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I cannot , in my wildest dreams, imagine how committing a Record, each time a single Field is changed, could be "...important to the overall use and intent of the database," but you can force an immediate Save by using the line

    DoCmd.RunCommand acCmdSaveRecord

    in the AfterUpdate event of each Control whose Value you want to Save immediately.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I too am curious about "...important to the overall use and intent of the database,..."

    To force a save, in the AfterUpdate event, I would use:

    Me.Dirty = FALSE

    RunCommand (IIRC) has been depreciated.

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    As my old signature used to say, "There's always more than one way to skin a cat!"

    RunCommand is alive and well, but if you prefer to use

    Me.Dirty = FALSE

    you should get used to testing if the Form is Dirty first, using

    If Me.Dirty Then Me.Dirty = FALSE

    as there are conditions (sorry, I can't remember exactly what conditions, off hand) that will pop an error if the former is used and the Form is not Dirty.

    DoCmd.RunCommand acCmdSaveRecord, on the other hand, won't pop the error.

    BTW, the Boys of Redmond would have us believe that VBA Code and Event Procedures are depreciated, also, in favor of Embedded Macros, but we know better than that, don't we? It's all a matter of personal preference! And, in point of fact, I usually use

    If Me.Dirty Then Me.Dirty = FALSE

    myself!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  7. #7
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I have seen

    Me.Dirty = FALSE

    but never tried it in without the IF test. The form I do use is

    If Me.Dirty Then
    Me.Dirty = FALSE

    End IF


    RE VBA Code/Event Procedures/Macros .......

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

Similar Threads

  1. Replies: 7
    Last Post: 05-14-2012, 08:33 PM
  2. Replies: 1
    Last Post: 02-08-2012, 04:50 PM
  3. Use a form to Update a table
    By j2curtis64 in forum Forms
    Replies: 0
    Last Post: 04-05-2011, 10:18 AM
  4. Update form with table info
    By Hannah's momma in forum Forms
    Replies: 0
    Last Post: 03-23-2011, 12:20 PM
  5. Replies: 2
    Last Post: 12-22-2010, 01:46 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