View Single Post
  #3  
Old May 18th, 2010, 02:36 PM posted to microsoft.public.access.forms
Mommybear
external usenet poster
 
Posts: 37
Default How to run event on other options

The fields in the form are bound, however, I have other fields that are not
on the form that default to a value, are calculated, being formatted to write
all caps, or go thru an if statement to determine value that are being
populated thru this Event procedure. The save button works great, however, I
don't know what is best in terms of handling the autosave when you tab or
enter past the last field on the screen. Do I duplicate the code or is there
a command that I could use to force this thru the save button code.

"John W. Vinson" wrote:

On Fri, 14 May 2010 10:39:01 -0700, Mommybear
wrote:

I created a data entry form with a Save button. This button runs thru a
procedure event which moves data to the proper fields, does a nested
if-then-else statement and other things. I understand that when you tab to
the last field, enter your data, then tab again or press enter, the new
record is automatically written to my database. However, this does not run
thru the code on my Save button. What is the easiest way to run this code.
I can add it to the event for enter and Tab functions, or is there a way to
tell it to run the Save_command procedure event. Also, what command do I
want to use to put the screen back to blank and ready for the next new record.


So I take it this is an unbound form (nothing in the textboxes' Control
Source) and that you've explicitly overridden the default form behavior in
exchange for doing it all in code? That's certainly doable but it's the hard
way!

To force a save to disk from a *bound* form all you need is your choice of
either:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord acForm, Me.Name, acNewRecord

or

If Me.Dirty Then Me.Dirty = False
DoCmd.GoToRecord acForm, Me.Name, acNewRecord

If the form is in fact unbound, you must parse out each field individually,
write it into the appropriate table record, and then explicitly set each field
to NULL. Doable but lots more work!
--

John W. Vinson [MVP]
.