How to Run Append Query (1 Viewer)

racemadnss

Registered User.
Local time
Today, 10:32
Joined
May 18, 2004
Messages
58
Im trying to Append most of the data from my incoming job form to my Schedule Job Form using an Append Query

I would like to Run the Append Query after the Form updates. Or everytime the user types in more information

Would this be a macro command or should this be Coded? If its coded what code would I need?


Thanks in Advance
 

Parker

Registered User.
Local time
Today, 16:33
Joined
Jan 17, 2004
Messages
316
racemadnss said:
Im trying to Append most of the data from my incoming job form to my Schedule Job Form using an Append Query

I would like to Run the Append Query after the Form updates. Or everytime the user types in more information

Would this be a macro command or should this be Coded? If its coded what code would I need?


Thanks in Advance

I would put it in the after update property of the form

Code:
Docmd.RunSQL
 

racemadnss

Registered User.
Local time
Today, 10:32
Joined
May 18, 2004
Messages
58
Ok, how would I tell the Do.cmd.RunSQL
to Run the Append Query. The Query is called "Append Schedule Jobs Query"

I need the Add Job form to add a Job to the Record, and Also put it on the schedule. B/C I always want the Job to be Availabe but the job wont always be on the schedule.

OR should I just put all the Fields From The Schedule file into the Job Table and have a Huge Table called Jobs
 

Parker

Registered User.
Local time
Today, 16:33
Joined
Jan 17, 2004
Messages
316
racemadnss said:
Ok, how would I tell the Do.cmd.RunSQL
to Run the Append Query. The Query is called "Append Schedule Jobs Query"


I wouldn't use a stored query in this instance. I would type the SQL into VBA and run it directly from there. Others may have other ideas

If you don't have any idea of what the code should look like then look at the SQL for your stored query. This will be similar and will give you an idea where to start but it will go something like this:

Code:
Private Sub Append_click()

On error GoTO Append_Click_Err
Dim db As Database, rst As DAO. Recordset

Set db = CurrentDb
Set rst = db.OpenRecordset ("SELECT * FROM yourtable WHERE [yourfield] ='" & Me![yourtable.yourfield] & " ' " , dbOpenDynaset)

With rst (etc,etc)

Append_Click_Exit:
Exit Sub

Append_Click_Err:
MsgBox Err. Description

Resume Append_Click_Exit

End Sub

This is only a quick example of how to insert SQL into a sub so don't try and use this as is.

It is imposible to tell you what the code will be without the knowledge of your db and what it is you are exactly wanting to achieve
 

Len Boorman

Back in gainfull employme
Local time
Today, 16:33
Joined
Mar 23, 2000
Messages
1,930
Not in the least disagreeing with Parker I personally use

Docmd.openquery "Your query name"
Docmd.close acquery,"Your query name"

Just my way

L
 

Parker

Registered User.
Local time
Today, 16:33
Joined
Jan 17, 2004
Messages
316
Len Boorman said:
Not in the least disagreeing with Parker I personally use

Docmd.openquery "Your query name"
Docmd.close acquery,"Your query name"

Just my way

L


I concur. The only reason that I suggested the long way was, while it’s slightly slower, I find it more flexible to build the SQL into code for this sort odf a task
 

Len Boorman

Back in gainfull employme
Local time
Today, 16:33
Joined
Mar 23, 2000
Messages
1,930
Question of sizing up the cat before deciding how to skin it. We all have our little ways.

I sometimes find a conflict with myself if giving advice. Always trying to suggest the Correct way of doing something but sometimes have a problem as to which is correct.

and frequently come to the conclusion that there is more than one correct solution.

L
 

Users who are viewing this thread

Top Bottom