472,790 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,790 software developers and data experts.

HELP WTH AUTOEXEC MACRO

Dear NG,

Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the Autoexec Macro looks like
the way to go. Could someone please assist?

Thank you very much!

Mike

Sep 29 '06 #1
6 6370
On 28 Sep 2006 18:57:25 -0700, Takeadoe wrote:
Dear NG,

Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the Autoexec Macro looks like
the way to go. Could someone please assist?

Thank you very much!

Mike
Each time the database is opened?
Create a macro
Macro Action OpenQuery (Your Update query Name)

Name this macro AutoExec

Perhaps you meant, more logically, once a day when the database is
opened.
Add a table to your database.
Table Name "tblUpdated"
FieldName "DateUpdated" indexed, No Duplicates)

Create a macro to first check the table to see if the Update has
already been done.

Macro Condition
DCount("*","tblUpdated","[DateUpdated] # = " & Date() & "#") =0

If date has already been added, cancel the macro.
Macro Action StopMacro

If not, run the update query.
Macro Action OpenQuery (Update query name)

Then run an append query to add the current date to the table.

Macro Action OpenQuery (Append query name which adds the current date
to the table.)

Name the macro AutoExec

If you wish to avoid the Query "You are about to Update ...etc...."
warnings, place a SetWarnings False macro just before the first
OpenQuery, and a SetWarnings True macro at after the last OpenQuery.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sep 29 '06 #2
Fred - Thanks so much for taking the time to respond. My reason for
wanting to run the update (once daily is probably sufficient as you
suggested) is to work around another problem that I've given up on
trying to conquer. Data captured at a scanner are automatically
appended to a database table. Problem is, I cannot for the life of me
figure out how to get Access to recognize a date/time value as a
date/time value. If I set the data type as date, the program crashes.
So, once in Access, I have to create 2 new variables of the date/time
format and parse the respective pieces from this text string. There
will be numerous occasions for folks to open this database while data
is being added. I don't want them to have to run the update query each
time they want to look at the data. When the table is complete, I will
likely run a make-table query and make the new variables permanent. As
you probably gathered, I know very little about Access. But, I'm
anxious to learn. I thought it would be neat if there was some way to
use the same functions that are used in the update query in the design
of the table so the new variables would be created automatically from
the original date/time text string. I'm all ears if you got
suggestions.

Again, thanks for taking YOUR time to help!

Mike

fredg wrote:
On 28 Sep 2006 18:57:25 -0700, Takeadoe wrote:
Dear NG,

Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the Autoexec Macro looks like
the way to go. Could someone please assist?

Thank you very much!

Mike

Each time the database is opened?
Create a macro
Macro Action OpenQuery (Your Update query Name)

Name this macro AutoExec

Perhaps you meant, more logically, once a day when the database is
opened.
Add a table to your database.
Table Name "tblUpdated"
FieldName "DateUpdated" indexed, No Duplicates)

Create a macro to first check the table to see if the Update has
already been done.

Macro Condition
DCount("*","tblUpdated","[DateUpdated] # = " & Date() & "#") =0

If date has already been added, cancel the macro.
Macro Action StopMacro

If not, run the update query.
Macro Action OpenQuery (Update query name)

Then run an append query to add the current date to the table.

Macro Action OpenQuery (Append query name which adds the current date
to the table.)

Name the macro AutoExec

If you wish to avoid the Query "You are about to Update ...etc...."
warnings, place a SetWarnings False macro just before the first
OpenQuery, and a SetWarnings True macro at after the last OpenQuery.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sep 29 '06 #3
Takeadoe wrote:
Fred - Thanks so much for taking the time to respond. My reason for
wanting to run the update (once daily is probably sufficient as you
suggested) is to work around another problem that I've given up on
trying to conquer. Data captured at a scanner are automatically
appended to a database table. Problem is, I cannot for the life of me
figure out how to get Access to recognize a date/time value as a
date/time value. If I set the data type as date, the program crashes.
Are you saying there'd be no need to run the query if you could get the
program to recognize the date?

How is the data coming into the app? What's the format string? What
does it look like? Give us an example of a date that crashes in a date
field?

Is there an error message?

Look at DateValue, DateSerial, and CDate in help to see if there is a
way to update the date when appended.

How is data "automatically appended" from a scanner? Does the scanner
recognize Access tables and mdbs? I should think there's some code that
appends the images.

I think if you provided some example code that occurs when appending
images and where it bombs or the process that you are currently using
you'll get some help here to overcome the crash.

So, once in Access, I have to create 2 new variables of the date/time
format and parse the respective pieces from this text string. There
will be numerous occasions for folks to open this database while data
is being added. I don't want them to have to run the update query each
time they want to look at the data. When the table is complete, I will
likely run a make-table query and make the new variables permanent. As
you probably gathered, I know very little about Access. But, I'm
anxious to learn. I thought it would be neat if there was some way to
use the same functions that are used in the update query in the design
of the table so the new variables would be created automatically from
the original date/time text string. I'm all ears if you got
suggestions.

Again, thanks for taking YOUR time to help!

Mike

fredg wrote:
>>On 28 Sep 2006 18:57:25 -0700, Takeadoe wrote:

>>>Dear NG,

Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the Autoexec Macro looks like
the way to go. Could someone please assist?

Thank you very much!

Mike

Each time the database is opened?
Create a macro
Macro Action OpenQuery (Your Update query Name)

Name this macro AutoExec

Perhaps you meant, more logically, once a day when the database is
opened.
Add a table to your database.
Table Name "tblUpdated"
FieldName "DateUpdated" indexed, No Duplicates)

Create a macro to first check the table to see if the Update has
already been done.

Macro Condition
DCount("*","tblUpdated","[DateUpdated] # = " & Date() & "#") =0

If date has already been added, cancel the macro.
Macro Action StopMacro

If not, run the update query.
Macro Action OpenQuery (Update query name)

Then run an append query to add the current date to the table.

Macro Action OpenQuery (Append query name which adds the current date
to the table.)

Name the macro AutoExec

If you wish to avoid the Query "You are about to Update ...etc...."
warnings, place a SetWarnings False macro just before the first
OpenQuery, and a SetWarnings True macro at after the last OpenQuery.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail

Sep 29 '06 #4
Salad - I will get back to you on this early next week (perhaps
today!). If you really want to get into this, I would be happy to
enlist your help, but I've traveled part way down this dusty road once
and I was unsuccessful. However, I didn't have an offer to help from
experts like yourself. I'll fill you in on the details as soon as I
get a chance.

salad wrote:
Takeadoe wrote:
Fred - Thanks so much for taking the time to respond. My reason for
wanting to run the update (once daily is probably sufficient as you
suggested) is to work around another problem that I've given up on
trying to conquer. Data captured at a scanner are automatically
appended to a database table. Problem is, I cannot for the life of me
figure out how to get Access to recognize a date/time value as a
date/time value. If I set the data type as date, the program crashes.

Are you saying there'd be no need to run the query if you could get the
program to recognize the date?

How is the data coming into the app? What's the format string? What
does it look like? Give us an example of a date that crashes in a date
field?

Is there an error message?

Look at DateValue, DateSerial, and CDate in help to see if there is a
way to update the date when appended.

How is data "automatically appended" from a scanner? Does the scanner
recognize Access tables and mdbs? I should think there's some code that
appends the images.

I think if you provided some example code that occurs when appending
images and where it bombs or the process that you are currently using
you'll get some help here to overcome the crash.

So, once in Access, I have to create 2 new variables of the date/time
format and parse the respective pieces from this text string. There
will be numerous occasions for folks to open this database while data
is being added. I don't want them to have to run the update query each
time they want to look at the data. When the table is complete, I will
likely run a make-table query and make the new variables permanent. As
you probably gathered, I know very little about Access. But, I'm
anxious to learn. I thought it would be neat if there was some way to
use the same functions that are used in the update query in the design
of the table so the new variables would be created automatically from
the original date/time text string. I'm all ears if you got
suggestions.

Again, thanks for taking YOUR time to help!

Mike

fredg wrote:
>On 28 Sep 2006 18:57:25 -0700, Takeadoe wrote:
Dear NG,

Can someone assist me with writing the little code that is needed to
run an update table query each time the database is opened? From what
I've been able to glean from this group, the Autoexec Macro looks like
the way to go. Could someone please assist?

Thank you very much!

Mike

Each time the database is opened?
Create a macro
Macro Action OpenQuery (Your Update query Name)

Name this macro AutoExec

Perhaps you meant, more logically, once a day when the database is
opened.
Add a table to your database.
Table Name "tblUpdated"
FieldName "DateUpdated" indexed, No Duplicates)

Create a macro to first check the table to see if the Update has
already been done.

Macro Condition
DCount("*","tblUpdated","[DateUpdated] # = " & Date() & "#") =0

If date has already been added, cancel the macro.
Macro Action StopMacro

If not, run the update query.
Macro Action OpenQuery (Update query name)

Then run an append query to add the current date to the table.

Macro Action OpenQuery (Append query name which adds the current date
to the table.)

Name the macro AutoExec

If you wish to avoid the Query "You are about to Update ...etc...."
warnings, place a SetWarnings False macro just before the first
OpenQuery, and a SetWarnings True macro at after the last OpenQuery.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Sep 29 '06 #5
Takeadoe wrote:
Salad - I will get back to you on this early next week (perhaps
today!). If you really want to get into this, I would be happy to
enlist your help, but I've traveled part way down this dusty road once
and I was unsuccessful. However, I didn't have an offer to help from
experts like yourself. I'll fill you in on the details as soon as I
get a chance.
OK

I might recommend you start a new thread. People don't go back to far
checking old messages.
Sep 29 '06 #6
Fair enough!
salad wrote:
Takeadoe wrote:
Salad - I will get back to you on this early next week (perhaps
today!). If you really want to get into this, I would be happy to
enlist your help, but I've traveled part way down this dusty road once
and I was unsuccessful. However, I didn't have an offer to help from
experts like yourself. I'll fill you in on the details as soon as I
get a chance.

OK

I might recommend you start a new thread. People don't go back to far
checking old messages.
Oct 5 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: MLH | last post by:
My autoexec macro in an Access 2.0 database has 2 lines. The first runs DoMenuItem - Database - Window - Hide. The second lines is Runcode - Initialize(). Initialize is a procedure in a global...
4
by: mvivar | last post by:
Hi everybody: This will be not easy to explain as my mother language is not english, so my apologies in advance if it sounds confusing. We have a database access 97 wich controls time of...
5
by: MLH | last post by:
I have problems getting the CTRL-d, CTRL-w and other 'hotkey combo' assignments to work in Access 97. I just imported the autoexec macro directly from Access 2.0, so its no surprise. Some are...
6
by: MLH | last post by:
Did A97, perchance, do away with the need for an AutoExec macro to initiate an autoexec sequence for databases? Or, must we still suffer with that hideous macro?
5
by: dick | last post by:
I can't seem to get AutoExec to run a function. Per an article on this group, I: 1) built a boolean function in a module that simply issues a MsgBox, then returns True 2) in AutoExec macro, I...
8
by: kini113 | last post by:
I want to update my database every night at 10pm. I have a Macro that runs all of the queries needed to update the database (which is also saved as a VBA module) and an AutoExec Macro to runs the...
4
by: kini113 | last post by:
I want to update my MS Access database every night at 10pm. I have a Macro that runs all of the queries needed to update the database (which is also saved as a VBA module) and an AutoExec Macro to...
4
by: kini113 | last post by:
I have 2 AutoExec macro's that run at a specified time every morning (1am) but 1 of those macros can't be run more then 1 time a day. I found a set up on a previous post that almost solves my...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.