query not working on form action

L

Lez

Hi Guys,

Have a form with a button to fire a number of queries to clear duplicate
data

'to ensure no duplicate items have been added to inventory table we run
these queries

1 looks for duplicates and adds to temp table
DoCmd.OpenQuery "qryStDup1", acViewNormal

2. Deletes duplicates records
DoCmd.OpenQuery "qryStDup2", acViewNormal

3. Appends temp data created at step one back to inventory teble
DoCmd.OpenQuery "qryStDup3", acViewNormal, acEdit

4. Finally deletes temporr data after append has completed
DoCmd.OpenQuery "qryStDup4", acViewNormal 'deletes the temp
duplicates table

Individually each of these queries work fine, however if I include these
behind a button, steps 1 and 2 work fine and step 3 fails to work. If I set
step 3 as an action on it's own behind a button that works fine

My question is...why will it not run as part of the full action under just
one button action button?


Thanks
Lez
 
K

Keith Wilby

Lez said:
My question is...why will it not run as part of the full action under just
one button action button?

Mine is ... why not set your table(s) up such that they don't accept
duplicates in the first place and save yourself all of this extra work? At
the very least you'll have less of a maintenance overhead and less file size
bloat.

Just my 2p worth :)

Keith.
www.keithwilby.com
 
M

Maurice

The last two are 'actionqueries'. Try it without the parameters and see if
that works..

So:
DoCmd.OpenQuery "qryStDup1", acViewNormal
DoCmd.OpenQuery "qryStDup2", acViewNormal
DoCmd.OpenQuery "qryStDup3"
DoCmd.OpenQuery "qryStDup4"

Furthermore if you leave the queries open in view mode how is the other
query to delete the table? There is a depended query who uses the table...

hth
 
L

Lez

Hi Keith, Maurice

Many thanks for your comments, both valid and helpful.

I had inherited this database to look after so still looking to find all the
errors, would agree and have now changed the table to not allow duplicates,
but had to provide an initial solution for the client.

All sorted now, many thanks
 

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