S
Sky Warren
Hello To All,
I have to many queries and want to know how to reduce them by streamlining
the actions into a more practical event module. Here's my problem. I have 12
different queries which return anniversary dates. The 12 anniversary queries
are all called by the main form which uses MSysObjects with the Like
statement that grabs everything with Anniversary as part of it's file name
and loads them into a combo box. The user then selects one of them and gets
back all people who meet the selected criterior. Here's the code for the main
form:
SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((MsysObjects.Name) Like "*Anniversary*") AND ((MsysObjects.Type)=5))
ORDER BY Val(MsysObjects.Name);
The 12 queries that return the anniversary dates only differ by number,
following are two examples for January and February:
SELECT Clients.[First Name], Clients.[Last Name], Clients.Address,
Clients.City, Clients.State, Clients.[Zip Code], Clients.[Policy Date]
FROM Clients
WHERE (((Clients.[Policy Date]) Like "1/*/*"))
ORDER BY DatePart("d",[Policy Date]);
SELECT Clients.[First Name], Clients.[Last Name], Clients.Address,
Clients.City, Clients.State, Clients.[Zip Code], Clients.[Policy Date]
FROM Clients
WHERE (((Clients.[Policy Date]) Like "2/*/*"))
ORDER BY DatePart("d",[Policy Date]);
What I would like to do is have the user type or select a number from 1
through 12 and generate a query based on their selection. That way, I could
eliminate all 12 anniversary queries. By the way, I have queries for
Birthdates too so that's about 24 queries I could eliminate.
I would think there's a way to do this, but I'm not much of a programmer.
Anyone care to tackle this one?
I have to many queries and want to know how to reduce them by streamlining
the actions into a more practical event module. Here's my problem. I have 12
different queries which return anniversary dates. The 12 anniversary queries
are all called by the main form which uses MSysObjects with the Like
statement that grabs everything with Anniversary as part of it's file name
and loads them into a combo box. The user then selects one of them and gets
back all people who meet the selected criterior. Here's the code for the main
form:
SELECT MsysObjects.Name
FROM MsysObjects
WHERE (((MsysObjects.Name) Like "*Anniversary*") AND ((MsysObjects.Type)=5))
ORDER BY Val(MsysObjects.Name);
The 12 queries that return the anniversary dates only differ by number,
following are two examples for January and February:
SELECT Clients.[First Name], Clients.[Last Name], Clients.Address,
Clients.City, Clients.State, Clients.[Zip Code], Clients.[Policy Date]
FROM Clients
WHERE (((Clients.[Policy Date]) Like "1/*/*"))
ORDER BY DatePart("d",[Policy Date]);
SELECT Clients.[First Name], Clients.[Last Name], Clients.Address,
Clients.City, Clients.State, Clients.[Zip Code], Clients.[Policy Date]
FROM Clients
WHERE (((Clients.[Policy Date]) Like "2/*/*"))
ORDER BY DatePart("d",[Policy Date]);
What I would like to do is have the user type or select a number from 1
through 12 and generate a query based on their selection. That way, I could
eliminate all 12 anniversary queries. By the way, I have queries for
Birthdates too so that's about 24 queries I could eliminate.
I would think there's a way to do this, but I'm not much of a programmer.
Anyone care to tackle this one?