Problem In Code?

D

DavidPuddyFan

Creating a database where I have two tables, a master table and a coun
table. Data Entry form based on master table. I have created an appen
and update query so after user puts in data for a part#, they clic
submit record...at this point the append query appends any records whe
cnt is greater then zero, then updates the master database back t
original state. If I run the queries manually, the process works great
but when I use the following, it doesn't work at all....

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

DoCmd.SetWarnings False
Dim stDocName As String
Dim stDocName1 As String
stDocName = "qAppendtoINVCNT"
stDocName1 = "updateMasterfile"
DoCmd.OpenQuery stDocName
DoCmd.OpenQuery stDocName1

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.Description
Resume Exit_Command19_Click

End Sub

Any Thoughts on how I can get this to work...what I am basically tryin
to accomplish is to only pull data from the master table that has bee
counted, then revert the master table back to original status...thank
in advance
 
G

glue

I think you have to use the execute method on action queries.

i.e.

CurrentDB.Execute stDocName
CurrentDB.Execute stDocName2

hth,

Aaro
 
S

Steve Schapel

David,

This code should work. Unlike a macro, a VBA procedure needs the
SetWarnings set back again afterwards, so you should have a
DoCmd.SetWarnings True line in your code. But that wouldn't cause the
queries to not function. However, as troubleshooting, you could try it
without turning the warnings off, to see if you can spot what is going
on, in other words just trim it down to...

Private Sub Command19_Click()
DoCmd.OpenQuery "qAppendtoINVCNT"
DoCmd.OpenQuery "updateMasterfile"
End Sub

.... and see what happens. I'd be interested to hear the outcome.
 
D

DavidPuddyFan

This is just very strange....I have added the set warnings true back i
after running the code, but it still does not work. However, if
comment out the set warnings false and true code, it works fine. An
ideas
 
D

DavidPuddyFan

This is just very strange....I have added the set warnings true back in
after running the code, but it still does not work. However, if I
comment out the set warnings false and true code, it works fine. Any
ideas?
 
S

Steve Schapel

David,

You mean without the SetWarnings lines in the code, the queries run?
They do what they are supposed to? And while they run, you get prompted
to confirm the appends and updates? And then, put the SetWarnings
lines back in, and nothing at all happens, the data doesn't get appended
or updated? If this is what you mean, sorry, I can't explain it.
 

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