Hi Alex,
There are a few things that come to mind.
CurrentDb.Execute executes "silently,"
i.e., there will be no warning message that you are
about to append some data to a table.
(the only message you will see is if the query fails
in some fashion)
This includes not showing the message that so many
records could not be appended because of violation
of indexes (I believe....but could be wrong).
So...if the table to which you are appending the records
has any "no-dup-type" indexes, then duplicate records
will not be appended "silently."
I know this may be silly to ask, but if you've run the query
previously, are you sure *more* records should be appended
when you run the same query again?
I suppose a simple test would be to start with an empty
table and run the code.
I mean no offense by suggesting the obvious.
good luck,
gary
Alex said:
I am not very familiar with how to do your 1st suggestion so i opted for
the
2nd. I basicaly cut and paste it into my code. No Error and no results (no
appending). I might be asking a lot from yo but you possibly help some
more?
thanks
--
Alex
Gary Walter said:
Hi Alex,
BTW, the last part of your WHERE
clause is redundant since condition
already in JOIN.
one other way:
Dim strSQL As String
strSQL = "INSERT INTO ArchiveEmployeeVacations " _
& "SELECT EmployeeVacations.* " _
& "FROM Employees INNER JOIN " _
& "(EmployeeVacations INNER JOIN [Temporary] " _
& "ON EmployeeVacations.EmployeeID = [Temporary].EmployeeID) " _
& "ON Employees.EmployeeID = EmployeeVacations.EmployeeID " _
& "WHERE EmployeeVacations.[From] <= Employees.[archivecalcdate];"
CurrentDb.Execute strSQL, dbFailOnError
:
The brakets did not work. The saved query is called "Append To
ArchiveEmployeVacations". The Query is an Append to a table. Here's the
code:
INSERT INTO ArchiveEmployeeVacations
SELECT EmployeeVacations.*
FROM Employees INNER JOIN (EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID) ON
Employees.EmployeeID
= EmployeeVacations.EmployeeID
WHERE (((EmployeeVacations.From)<=([employees].[archivecalcdate])) AND
((EmployeeVacations.EmployeeID)=[employees].[employeeid]));
When run alne it works fine and returns results in the appended table.
Thanks
--
Alex
:
:
Hi Dave
Thanks but didn't work I tried the DoCmd.RunSQL and it didn't work.
It
goes
through its paces as if its doing something yet no results. But when
I
run
the Qury itself it works fine. So I the code is fine. Where' my
problem??
Thanks
--
Alex
:
Hi Alex
Use:
DoCmd.OpenQuery "yourQuery"
Rgds
Hi Alex,
..RunSQL requires an "action" query
(or a data-definition query).
Does your saved query return rows?
-- then OpenQuery should work
Some gotchas are:
1) query name with spaces must be enclosed
with brackets
DoCmd.OpenQuery "[Sales Totals Query]"
2) a query that references controls on a form
will not work for .RunSQL (and maybe .OpenQuery)
If this does not help, please post
name and sql of stored query.
Thanks,
gary