Group:  Microsoft Access ยป microsoft.public.access.queries
Thread: append queries

append queries
"Haggr1 via AccessMonster.com" <u35393[ at ]uwe> 12/30/2008 11:23:27 PM
I have 3 append queries I would like to run at the same time from one
"command button" without warning messages. But before they run, I need to
delete all records in the [Table] I am appending. Below are the 3 queries.
Thanks

INSERT INTO ImportDateDue ( Job, Due )
SELECT [Date Due].[Job Number], [Date Due].[Date Due]
FROM [Date Due]
WHERE ((([Date Due].[Date Due])>Now()-1));

INSERT INTO ImportDateDue ( Job, Due )
SELECT Import.Job, Import.Due
FROM Import
WHERE (((Import.Due)>Now()-"1"));

INSERT INTO ImportDateDue ( Job, Item, Ordered, Age )
SELECT Import.Job, Import.Item, Import.Ordered, Import.Age
FROM Import
WHERE (((Import.Ordered)<Date()-3));

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200812/1

RE: append queries
Clifford Bass 12/30/2008 11:56:01 PM
Hi,

You can do something like this:

DoCmd.SetWarnings False
DoCmd.RunSQL "delete from tablename'"
DoCmd.RunSQL "insert ..."
DoCmd.RunSQL "insert ..."
DoCmd.RunSQL "insert ..."
DoCmd.SetWarnings True

Clifford Bass

"Haggr1 via AccessMonster.com" wrote:

[Quoted Text]
> I have 3 append queries I would like to run at the same time from one
> "command button" without warning messages. But before they run, I need to
> delete all records in the [Table] I am appending. Below are the 3 queries.
> Thanks
>
> INSERT INTO ImportDateDue ( Job, Due )
> SELECT [Date Due].[Job Number], [Date Due].[Date Due]
> FROM [Date Due]
> WHERE ((([Date Due].[Date Due])>Now()-1));
>
> INSERT INTO ImportDateDue ( Job, Due )
> SELECT Import.Job, Import.Due
> FROM Import
> WHERE (((Import.Due)>Now()-"1"));
>
> INSERT INTO ImportDateDue ( Job, Item, Ordered, Age )
> SELECT Import.Job, Import.Item, Import.Ordered, Import.Age
> FROM Import
> WHERE (((Import.Ordered)<Date()-3));
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200812/1
>
>
RE: append queries
"Haggr1 via AccessMonster.com" <u35393[ at ]uwe> 12/31/2008 3:56:40 PM
Is this correct

Private Sub Command162_Click()
DoCmd.Close

On Error GoTo Err_Command162_Click
DoCmd.SetWarnings False
DoCmd.RunSQL "delete from ImportDateDue'"
DoCmd.RunSQL "INSERT INTO ImportDateDue ( Job, Due )"
SELECT [Date Due].[Job Number], [Date Due].[Date Due]
FROM [Date Due]
WHERE ((([Date Due].[Date Due])>Now()-1));"
DoCmd.RunSQL "INSERT INTO ImportDateDue ( Job, Due )"
SELECT Import.Job, Import.Due
FROM Import
WHERE (((Import.Due)>Now()-"1"));"
DoCmd.RunSQL "INSERT INTO ImportDateDue ( Job, Item, Ordered, Age )"
SELECT Import.Job, Import.Item, Import.Ordered, Import.Age
FROM Import
WHERE (((Import.Ordered)<Date()-3));"
DoCmd.SetWarnings True


Err_Command162_Click:
MsgBox Err.Description
Resume Exit_Command162_Click

End Sub

Clifford Bass wrote:
[Quoted Text]
>Hi,
>
> You can do something like this:
>
>DoCmd.SetWarnings False
>DoCmd.RunSQL "delete from tablename'"
>DoCmd.RunSQL "insert ..."
>DoCmd.RunSQL "insert ..."
>DoCmd.RunSQL "insert ..."
>DoCmd.SetWarnings True
>
> Clifford Bass
>
>> I have 3 append queries I would like to run at the same time from one
>> "command button" without warning messages. But before they run, I need to
>[quoted text clipped - 15 lines]
>> FROM Import
>> WHERE (((Import.Ordered)<Date()-3));

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200812/1

Home | Search | Terms | Imprint
Newsgroups Reader