When does a record entered thru form appear in underlying table.

C

Chrisso

Hi All

I have a form that sits straight on top of a table. I enter new records
by hitting the ">*" button for a new record and then filling out the
fields.

Can anyone tell me when this record will appear in the actual table?

It seems to appear after the form is closed but I want to run an append
query on the newly added record before I close down the form but at
this stage the info I have entered does not appear in the underlying
table.

Can I make some sort of commit call to force this new record into the
table so that I can then run my query to append that data to another
table? Or is this bad practice?

Chrisso
 
S

strive4peace

Hi Chrisso,

the record is written automatically when you move off it -- to another
record or close the form.

You can force the record to save to the disk by clicking on the pencil
icon that appears in the record selector area to the left as you start
typing.

You can also use code to see if a record needs to be saved and, if so, do it

'~~~~~
'save record if changes have been made
If me.Dirty Then Me.Dirty = false
'~~~~~

If you are going to run an Append query in code, make sure you do this
afterward:

currentdb.tabledefs.refresh
DoEvents

so that other processes/users see the changes


Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
C

Chrisso

Thanks Crystal

Exactly what I needed. Thanks for the advice as well - all working
well.

Chrisso
 
S

strive4peace

you're welcome, Chrisso ;) happy to help

Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 
S

strive4peace

I wish to explain something that was not worded well...

'so that other processes/users see the changes'

--- <quote> ---
If you are going to run an Append query in code, make sure you do this
afterward:

currentdb.tabledefs.refresh
DoEvents

so that other processes/users see the changes
--- </quote> ---

~~ Refresh ~~

when you run an action SQL statement, the data in the form may not
necessarily 'see' the changes right away -- since changes to the data
were made by another process

when there are a series of action queries in code, it is best to refresh
the tabledefs collection between each so the successive queries see the
data the way it is after the query (instead of before)

using Refresh on the Tabledefs collection 'Updates the objects in a
collection to reflect the current database's schema' (from Help)

DoEvents may not be neccessary, but I use it out of habit to 'cement'
the changes and make them show up right away -- not always a good thing
to do since it also slows things down and can mess up certain things
(like looping through a list of files with Dir)

~~ DoEvents ~~

DoEvents is used to make VBA pay attention to what is currently
happening and look to see if the OS (Operating System) has any requests.

ie: if you have a loop and want to be able to BREAK it with CTRL-BREAK,
put DoEvents into the loop

DoEvents will also update values written to a form by a general
procedure or code behind another form or report

A DoEvents is done when you use MsgBox, or are stepping through code
(since it has to pay attention to the keyboard)

It is a good way to say, "Wake Up!"




Warm Regards,
Crystal
*
:) have an awesome day :)
*
MVP Access
Remote Programming and Training
strive4peace2006 at yahoo.com
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top