View Full Version : Macro running numerous queries with criteria


the_metallian
09-02-2003, 05:03 AM
Hi,

I wonder if anyone can help me. I want to create a macro that will run a series of update and delete queries. The problem is, they all have a critera, which the user will have to type in a number of times, even though it is the same criteria they are entering. Does anyone know a way around this?

namliam
09-02-2003, 05:12 AM
Yep, Use VBA instead of macro's

Search the forum on running query's from vba (docmd.openquery or docmd.runsql [better way than runsql: currentdb.execute]) or read this FAQ (http://www.accessvba.com/showthread.php?s=&threadid=2640)

Post any further questions if you have em....

RegardsZzzzzz

The Mailman

the_metallian
09-02-2003, 06:20 AM
Ummmm, I'm quite a beginner at Access, and I've only ever used VB in Excel. I dont really understand much of that. I can show you the SQL of the queries I want to run, and I also want to open a report that requires a criteria input. The thing is, the user would have to type it in 3 times.

This update query will be run:

UPDATE (tblUserInfo INNER JOIN tblHardware ON tblUserInfo.[User UK ID] = tblHardware.[User UK ID]) INNER JOIN tblsoftware ON tblUserInfo.[User UK ID] = tblsoftware.[User UK ID] SET tblHardware.[Returned?] = Yes, tblHardware.[CMDB Updated] = Yes, tblsoftware.[Cleared?] = Yes, tblUserInfo.[Completed?] = Yes
WHERE (((tblUserInfo.[User UK ID]) Like "*" & [Enter UK ID] & "*"));

Then a report that displaying that information, meaning the criteria will need to be entered again.

Then if required this delete query:

DELETE tblUserInfo.[User UK ID], tblUserInfo.[User Name], tblUserInfo.[User UK ID], tblUserInfo.Location, tblUserInfo.[Date to Leave], tblUserInfo.[Contact Number], tblUserInfo.Manager, tblUserInfo.[Completed?]
FROM tblUserInfo
WHERE (((tblUserInfo.[User UK ID]) Like "*" & [Enter UK ID] & "*"));

Really appreciate any help!

namliam
09-03-2003, 02:44 AM
Did you read this? (http://www.accessvba.com/showthread.php?s=&threadid=2640)

Also Read this (http://www.accessvba.com/showthread.php?s=&threadid=2791)

Regards