Hi,
I am not sure if you are running the second sql based on a query. I find
every time I do it and try to run an sql or query with code I get the
same
the same message. I know there is a more correct way of doing it but I
find
running a make table query and then run a query based on the resulting
table
solves the problem.
Hennie
Hi Jerry,
Thanks for your reply, maybe I should be doing this in VBA. What I am
trying to acheive is this:
I have one table (tbl01_Services) with a list of services that are
imported
from a text file, and an unrelated table (tbl01_PermSrvcsIgnore) that
contains a list of services that can be ignored (ie. set the [valid]
field
in
tbl01_services to 0 if it finds a match in tbl01_PermSrvcsIgnore). In
the
tbl01_PermSrvcsIgnore, the field 'Server' can have an individual Server
name,
or 'ALL'.
I run these two queries when data is first imported and they work fine:
' In the Services Table, set all valid to 0 for entries marked 'ALL' in
the
AddPermNoMon table
strSQL4 = "UPDATE tbl01_Services, tbl01_PermSrvcsIgnore SET
tbl01_Services.Valid = 0 " & vbCrLf & _
"WHERE (((tbl01_PermSrvcsIgnore.Server) Like ""ALL"") AND
((tbl01_Services.Service) Like [Service Name]) AND
((tbl01_Services.ImpDate)
Is Null));"
' In the Services Table, set all valid to 0 for entries marked for
specific
Servers.
' in the AddPermNoMon table
strSQL5 = "UPDATE tbl01_Services, tbl01_PermSrvcsIgnore SET
tbl01_Services.Valid = 0 " & vbclrf & _
"WHERE (((tbl01_Services.Server) Like [tbl01_PermSrvcsIgnore]![Server])
AND
((tbl01_Services.Service) Like [tbl01_PermSrvcsIgnore]![Service Name])
AND
((tbl01_Services.ImpDate) Is Null));"
Of the two SQL statements above, one updates services found with server
status of 'ALL', and the other updates individual server names, and
both
queries work with any records that have not yet been datestamped (ie.
((tbl01_Services.ImpDate) Is Null));
Now what I am trying to acheive is to do the same thing as above (after
records have been imported) and after the records have been
datestamped.
I am also trying to factor in which type of records I want to update
(ie
the
SQL below i have included the ImpDate and the Type).
The ImpDate is the datestamp, and the Type field can be PROD or DEV.
The ImpDate and Type do not matter in the above SQL because I can
compare
all records with no date stamp. However they do matter below.
I thought it would be a simple case (it was 03:00 am
) of just
changing:
(tbl01_Services.ImpDate) Is Null to (tbl01_Services.ImpDate) =
Forms![ProcessErr]![cmbImpDate]
And adding:
((tbl01_PermSrvcsIgnore.Type)=[forms]![ProcessErr]![cmbShutType]))
But when I do this, I get the two few parameters error.
Why does it work fine in the first SQL, but bomb in the second?
:
You are attempting to update two tables at the same time. It's very
unlikely
that you can do this. Instead you need to update one table then the
other.
Also you won't be able to use a direct joing on the two tables in the
Where
clause. You'll probably need a subquery using an In or Exists clause.
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.
:
Can anyone advise why I am getting a 'Too few parameters - Expected
2'
with
these two SQL statement?
strSQL1 = "UPDATE tbl01_PermSrvcsIgnore, tbl01_Services SET
tbl01_Services.Valid = 0 " & _
"WHERE (((tbl01_Services.Server)=[tbl01_PermSrvcIgnore]![Server])
AND
((tbl01_Services.Service)=[Service Name]) =
((tbl01_PermSrvcsIgnore.Type)=[forms]![ProcessErr]![cmbShutType]));"
strSQL2 = "UPDATE tbl01_Services, tbl01_PermSrvcsIgnore SET
tbl01_Services.Valid = 0 " & _
"WHERE (((tbl01_PermSrvcsIgnore.Server) Like ""ALL"") AND
((tbl01_Services.Type) = [forms]![ProcessErr]![cmbShutType]) AND
((tbl01_Services.Service) = [Service Name]) AND
((tbl01_Services.ImpDate) =
[forms]![ProcessErr]![cmbImpDate]));"
Any assistance would be greatly appreciated...
Cheers,
GT.
.