APPEND QUERY RUNS ON ITS OWN BUT NOT IN A MACRO

A

ALLAN_ASHFORD

Hi All

A database I created for a client some years ago has a macro which contains
an append query. This macro repeats itself until a condition is met and has
run thousands of times without any problem.

The client has asked that I make the database work for multiple factories.
Without going into too much detail the same macro and append query are needed
in the spin-off databases (one for each factory).

The problem is that the append query will not run in any of the spin-off
databases as part of the macro although the macro itself is unchanged, but
will run in isolation when it performs correctly and gives no error messages.
I have run the macro with SetWarnings ON, but only get the warnings that you
would normally expect.

I have pasted over the macro, the append query and the underlying select
queries from the original database, but to no effect.

Please has anyone any ideas on what is happening? I have spent nearly 2 days
on this without any success.

Many thanks in advance for any guidance offered.

Allan Ashford
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

Not quite sure what you mean by "points it to a particular form or table".
The Append Query takes data from a Select Query which in turn takes data from
tables and queries and should append it to a linked table, but doesn't!!

Hope this helps.

Allan

Gina said:
Allan,

Is there anything in the Append query that points it to a particular form or
table?
[quoted text clipped - 27 lines]
Allan Ashford
 
G

Gina Whipp

Allan,

Sometimes in the query you can have a field pointing to a particular field
in a form and the reason the query fails is because when you reused the
query that form is not there. OR something else on the criteria line is
causing the records to go nowhere. Copy/Paste the SQL of the query here and
let's see if that is the case here.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

Not quite sure what you mean by "points it to a particular form or table".
The Append Query takes data from a Select Query which in turn takes data
from
tables and queries and should append it to a linked table, but doesn't!!

Hope this helps.

Allan

Gina said:
Allan,

Is there anything in the Append query that points it to a particular form
or
table?
[quoted text clipped - 27 lines]
Allan Ashford
 
F

Fred

A couple of "narrowing down" ideas. Test/see if:

The same query will run in a different (one step) macro
A different query will run in that macro
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

Here is the code:-

INSERT INTO [20 - RAW MATERIALS FOR ASSIGNED BOMs] ( [ASSIGNED REFERENCE],
MATCODE, DESCRIPTION, [QTY REQ] )
SELECT [20 - CALCULATE RAW MATERIALS FOR LINE].AUTONUMBER, [20 - CALCULATE
RAW MATERIALS FOR LINE].MATCODE, [20 - CALCULATE RAW MATERIALS FOR LINE].
DESCRIPTION, [20 - CALCULATE RAW MATERIALS FOR LINE].Expr1
FROM [20 - CALCULATE RAW MATERIALS FOR LINE];

A typical line from the select Query 20 - CALCULATE RAW MATERIALS FOR LINE IS
as follows:-

19349 135/PLAYINGCARDS BLACK PLAYING CARDS/210gsm in printed box
1000

Allan


Gina said:
Allan,

Sometimes in the query you can have a field pointing to a particular field
in a form and the reason the query fails is because when you reused the
query that form is not there. OR something else on the criteria line is
causing the records to go nowhere. Copy/Paste the SQL of the query here and
let's see if that is the case here.
[quoted text clipped - 18 lines]
 
G

Gina Whipp

Allan,

A couple of questions...

1. What is this field? [20 - CALCULATE RAW MATERIALS FOR LINE].Expr1
2. Perhaps showing the SQL of 20 - CALCULATE RAW MATERIALS FOR LINE would
help...
3. Do you get records returned when you run 20 - CALCULATE RAW MATERIALS
FOR LINE?
4. QTY REQ sounds like a numeric field, when you run the query (without
actually appending anything) is there any text in that field?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

Here is the code:-

INSERT INTO [20 - RAW MATERIALS FOR ASSIGNED BOMs] ( [ASSIGNED REFERENCE],
MATCODE, DESCRIPTION, [QTY REQ] )
SELECT [20 - CALCULATE RAW MATERIALS FOR LINE].AUTONUMBER, [20 - CALCULATE
RAW MATERIALS FOR LINE].MATCODE, [20 - CALCULATE RAW MATERIALS FOR LINE].
DESCRIPTION, [20 - CALCULATE RAW MATERIALS FOR LINE].Expr1
FROM [20 - CALCULATE RAW MATERIALS FOR LINE];

A typical line from the select Query 20 - CALCULATE RAW MATERIALS FOR LINE
IS
as follows:-

19349 135/PLAYINGCARDS BLACK PLAYING CARDS/210gsm in printed box
1000

Allan


Gina said:
Allan,

Sometimes in the query you can have a field pointing to a particular field
in a form and the reason the query fails is because when you reused the
query that form is not there. OR something else on the criteria line is
causing the records to go nowhere. Copy/Paste the SQL of the query here
and
let's see if that is the case here.
[quoted text clipped - 18 lines]
Allan Ashford
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

1. Expr1 is the field giving the quantity required to be appended to QTY
REQ

2. SELECT [20 - NEXT PLAN ORDER LINE TO BE ADDED TO RAW MATERIALS].
AUTONUMBER, [PRODCOST COMPONENTS].MATCODE, [PRODCOST COMPONENTS].DESCRIPTION,
[PRODCOST COMPONENTS].QTY, [PRODCOST COMPONENTS]![QTY]*[20 - NEXT PLAN ORDER
LINE TO BE ADDED TO RAW MATERIALS]![QTY ORDERED] AS Expr1
FROM [20 - NEXT PLAN ORDER LINE TO BE ADDED TO RAW MATERIALS] INNER JOIN
[PRODCOST COMPONENTS] ON [20 - NEXT PLAN ORDER LINE TO BE ADDED TO RAW
MATERIALS].[PRODUCT CODE] = [PRODCOST COMPONENTS].PRODCODE;

3. Yes

4. Running 20 - APPEND RAW MATERIALS RE LOWEST ASSIGNED BOM as a Select
Query shows the data that needs to be appended

Gina said:
Allan,

A couple of questions...

1. What is this field? [20 - CALCULATE RAW MATERIALS FOR LINE].Expr1
2. Perhaps showing the SQL of 20 - CALCULATE RAW MATERIALS FOR LINE would
help...
3. Do you get records returned when you run 20 - CALCULATE RAW MATERIALS
FOR LINE?
4. QTY REQ sounds like a numeric field, when you run the query (without
actually appending anything) is there any text in that field?
[quoted text clipped - 30 lines]
 
G

Gina Whipp

Allan,

Forgot to ask Access version?

And if I am understanding you... running the query appends the records BUT
running it from the macro does not work. Since the query appears fine.
What are the macro settings at in each front end or at each location?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

1. Expr1 is the field giving the quantity required to be appended to
QTY
REQ

2. SELECT [20 - NEXT PLAN ORDER LINE TO BE ADDED TO RAW MATERIALS].
AUTONUMBER, [PRODCOST COMPONENTS].MATCODE, [PRODCOST
COMPONENTS].DESCRIPTION,
[PRODCOST COMPONENTS].QTY, [PRODCOST COMPONENTS]![QTY]*[20 - NEXT PLAN
ORDER
LINE TO BE ADDED TO RAW MATERIALS]![QTY ORDERED] AS Expr1
FROM [20 - NEXT PLAN ORDER LINE TO BE ADDED TO RAW MATERIALS] INNER JOIN
[PRODCOST COMPONENTS] ON [20 - NEXT PLAN ORDER LINE TO BE ADDED TO RAW
MATERIALS].[PRODUCT CODE] = [PRODCOST COMPONENTS].PRODCODE;

3. Yes

4. Running 20 - APPEND RAW MATERIALS RE LOWEST ASSIGNED BOM as a
Select
Query shows the data that needs to be appended

Gina said:
Allan,

A couple of questions...

1. What is this field? [20 - CALCULATE RAW MATERIALS FOR LINE].Expr1
2. Perhaps showing the SQL of 20 - CALCULATE RAW MATERIALS FOR LINE would
help...
3. Do you get records returned when you run 20 - CALCULATE RAW MATERIALS
FOR LINE?
4. QTY REQ sounds like a numeric field, when you run the query (without
actually appending anything) is there any text in that field?
[quoted text clipped - 30 lines]
Allan Ashford
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

Access 2000

Being self-taught I'm not sure what you mean by "macro settings at in each
front end or at each location?". However the database from which the problem
database was derived runs in parallel presumeably under the same
configuration (local & network) without any problem as the one that is giving
the problem so the macro settings (whatever they are) should be the same. Can
you please give me some pointers to check?

Sorry I can't be of more help, but having used Access for 15 years this is
the first time I have come across a problem I haven't managed to solve.

Allan

Gina said:
Allan,

Forgot to ask Access version?

And if I am understanding you... running the query appends the records BUT
running it from the macro does not work. Since the query appears fine.
What are the macro settings at in each front end or at each location?
[quoted text clipped - 35 lines]
 
G

Gina Whipp

Allan,

I THINK this applies to Access 2000, I forget when this started. To check
the Macro Settings, which is via Access not via the network, follow these
steps...

1. Open any database
2. Go to Tools... Macro... click Security...
3. On the machine that works check the setting but it sounds like it's set
to Low. Insure all the other machines are set the same way. Yep, you get a
message about being unsafe... just say Yes or OK.

Let's see if that's the problem.

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

Access 2000

Being self-taught I'm not sure what you mean by "macro settings at in each
front end or at each location?". However the database from which the
problem
database was derived runs in parallel presumeably under the same
configuration (local & network) without any problem as the one that is
giving
the problem so the macro settings (whatever they are) should be the same.
Can
you please give me some pointers to check?

Sorry I can't be of more help, but having used Access for 15 years this is
the first time I have come across a problem I haven't managed to solve.

Allan

Gina said:
Allan,

Forgot to ask Access version?

And if I am understanding you... running the query appends the records
BUT
running it from the macro does not work. Since the query appears fine.
What are the macro settings at in each front end or at each location?
[quoted text clipped - 35 lines]
Allan Ashford
 
A

AccessVandal via AccessMonster.com

Macro Security is only avialable in 2003 and 2007. For 2000 there's no
security for macros. What Gina is refering to is the end users PC, what
version are they using? If it is 2003 or 2007, you might want to ask them to
to disable macros for this test. If they are using 2007, make sure the
database is in Trusted locations.

You might want to check for WorkGroup Security just in case even the
owner/user or the Admin user setting was incorrect where the user might not
be able to execute the database macro. You can go to the security - user and
group permissions - object type - select the your macro name and make sure
they have the neccessary permission. They are open/run, read design, modify
design, administer. I doubt it, as it is very unlikely that someone might
change this, but than again who knows? (even if you don't use workgroup
security, it still worthwhile to check just in case someone setup user
security accidentaly). 2007 format databse(accdb) does not support workgroup
security.
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

I'll check security out in the morning (I'm UK based nand it's now 2.15 am).
But I'm running both databases on the same PC under Access 2000 and both with
linked tables onto the same other PC across my own network, i.e. I'm still at
the testing stage, so none of the modifications have been loaded onto the
clients's PCs.

Allan

Gina said:
AccessVandal,

Thanks, I wasn't sure if that was available in 2000.
Macro Security is only avialable in 2003 and 2007. For 2000 there's no
security for macros. What Gina is refering to is the end users PC, what
[quoted text clipped - 36 lines]
 
G

Gina Whipp

Allan,

Then the Macro Security is not an option if using Access 2000. How is the
macro run? Is it a button on a form? What is the code?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

I'll check security out in the morning (I'm UK based nand it's now 2.15
am).
But I'm running both databases on the same PC under Access 2000 and both
with
linked tables onto the same other PC across my own network, i.e. I'm still
at
the testing stage, so none of the modifications have been loaded onto the
clients's PCs.

Allan

Gina said:
AccessVandal,

Thanks, I wasn't sure if that was available in 2000.
Macro Security is only avialable in 2003 and 2007. For 2000 there's no
security for macros. What Gina is refering to is the end users PC, what
[quoted text clipped - 36 lines]
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

The macro that has the problem runs from within another macro which is
activated by clicking a button on a form. The problem macro has a Repeat
Count of 200 and a Repeat Expression in the form of a Form that shows the
difference between 2 numbers and runs whilst this difference is >0.

Gina said:
Allan,

Then the Macro Security is not an option if using Access 2000. How is the
macro run? Is it a button on a form? What is the code?
[quoted text clipped - 18 lines]
 
G

Gina Whipp

Allan,

Have you you tried *Stepping* thru the macro? Also can you post the Actions
of the Macro here? Since both databases are connected to the same back-end,
are you running them at the same time?

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

The macro that has the problem runs from within another macro which is
activated by clicking a button on a form. The problem macro has a Repeat
Count of 200 and a Repeat Expression in the form of a Form that shows the
difference between 2 numbers and runs whilst this difference is >0.

Gina said:
Allan,

Then the Macro Security is not an option if using Access 2000. How is the
macro run? Is it a button on a form? What is the code?
[quoted text clipped - 18 lines]
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

Have tried stepping but still no success.

Sorry to seem so dim, but how do I post the Macro Actions?

I am not running the 2 databases simultaneously, they merely sit alongside
each other on the local hard drive and the 2 back-ends likewise on the other
PC.

Gina said:
Allan,

Have you you tried *Stepping* thru the macro? Also can you post the Actions
of the Macro here? Since both databases are connected to the same back-end,
are you running them at the same time?
[quoted text clipped - 13 lines]
 
G

Gina Whipp

Allan,

No need to be sorry... now once you do you will have learned something new
today! Unfortunately, no easy way to do this... You have to open the Macro
and type each line

Action
blah

Action Arguements
blah
blah
etc...

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II

http://www.regina-whipp.com/index_files/TipList.htm

ALLAN_ASHFORD via AccessMonster.com said:
Hi Gina

Have tried stepping but still no success.

Sorry to seem so dim, but how do I post the Macro Actions?

I am not running the 2 databases simultaneously, they merely sit alongside
each other on the local hard drive and the 2 back-ends likewise on the
other
PC.

Gina said:
Allan,

Have you you tried *Stepping* thru the macro? Also can you post the
Actions
of the Macro here? Since both databases are connected to the same
back-end,
are you running them at the same time?
[quoted text clipped - 13 lines]
 
A

ALLAN_ASHFORD via AccessMonster.com

Hi Gina

This is the macro that is giving the problem:-

Set Warnings Warnings On No

Close Form 20 - FIND HIGHEST/LOWEST
DIFFERENCE COUNT FORM

Save Prompt

OpenQuery 20 - FIND LOWEST UNADDED
LINE

View Datasheet

Data Mode: Edit

***************************************************************************************************

OpenQuery 20 - APPEND RAW MATERIALS
RE LOWEST
ASSIGNED BOM

View Datasheet

Data Mode: Edit


This is the Query that doesn't work in the Macro
****************************************************************************************************

OpenQuery 20 - HIGHEST ASSIGNED BOM
LINE

View Datasheet

Data Mode: Edit


OpenQuery 20 - FLAG BOM LINE AS
ASSIGNED TO RAW MATERIALS

View Datasheet

Data Mode: Edit


OpenForm 20 - FIND HIGHEST/LOWEST DIFFERENCE COUNT FORM

View: Form
Filter Name:
Where Condition:
Data Mode: -1
Window Mode: Hidden


The Form is needed to give the Repeat Expression condition in the parent
macro.

Allan

Gina said:
Allan,

No need to be sorry... now once you do you will have learned something new
today! Unfortunately, no easy way to do this... You have to open the Macro
and type each line

Action
blah

Action Arguements
blah
blah
etc...
[quoted text clipped - 20 lines]
 

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