Autoexec

  • Thread starter Thread starter Wally
  • Start date Start date
W

Wally

Hello everyone,
If anyone can help with this problem I'd be grateful.

I have a form that updates information in recordsource
tables based on current values and date values changed
using the after_update event of certain controls. Also,
upon opening the form the from_current event actually
calls these after_update events as to bring all data up to
date as one scolls thru the records (if it's not a new
record). This works great, but my problem is this.

I want to create a report based on the same recordset, but
it is not going to be current data if the user doesn't
manually go thru each record on the form. So I want to
open the form(hidden) in an autoexec macro or sub
(preferably a sub) to automatically update all records
everytime the database is opened. Is there a simple way
to do this. I'm having trouble getting anything I try to
work.

Thanks for any advice,
Wally
 
You could have your startup form in Tools|Startup call this form in hidden
window mode or, perhaps, just run this code from the form you do have show.
To keep the user from doing anything until the code completes, you could set
the cursor to an hourglass until you are done.

DoCmd.Hourglass True
 
Thanks for the response Wayne

I alredy have a Switchboard form that starts up
automatically on loading. What I need is a macro that
calls a Sub Procedure that opens the Form in hidden mode.

What I don't know how to do really is in this Sub
Procedure, loop through all the records one at a time.
This will cause the on_current event to launch each time
updating each control with new data based on that days
date.

Something like;
recordset.movefirst
With Each record in recordset (Don't know how to do this)
recordset.movenext (Recordset that is behind the form)
End With

Maybe I have to do this in another event procedure of the
form itself. Like On_Load or On_Activate or On_Open.

I hope this explains better what I need to do.
Basically the On_Current event of the Form has the code
to update the controls on the form but only the records
currently displayed are updated. So if I run a Report
first thing in the morning w/o manually going thru all
the records using the form, no records are updated using
today's date.

I can use the Docmd.hourglass to pause everything till
update is complete though.
Thanks,
Wally
 
Why not run an Update Query on the table(s) when the switchboard opens? You could do that
in the OnOpen event of the switchboard form.

CurrentDb.Execute strSQL, dbFailOnError
 
Wayne,
There's too much logic and code involved to use an update
query.
I can open the form in hidden mode. That's no problem. I
just need to be able to programmatically move through each
record while the form is hidden, so that the _current
event is called and run. Like I said each record is
update by the _current event of the form.

Thanks again,
Wally

-----Original Message-----
Why not run an Update Query on the table(s) when the
switchboard opens? You could do that
 
Wayne,
After thinking about it a little, an update query might be
just the thing I need after learning that I can call a
function to return the correct value to update.
This might cause me to redo the code in my events also to
clean things up a little.

Thanks a bunch,
Wally
-----Original Message-----
Why not run an Update Query on the table(s) when the
switchboard opens? You could do that
 
If you need help with it you know where to find us. I think you'll find the query to be
MUCH faster than stepping through each record.
 
Back
Top