Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter Query

Status
Not open for further replies.

goslincm

MIS
May 23, 2006
292
US
Hi all. I am working on an append query that will take a set of records I've identified as missing for the year 2006 and append them into an existing table that has a field [year] in it and various records from other years.

I'm not sure how to set up my append query so that the value being entered into the parameter will be the value that goes into the field [year].
I need this append query to be both an append an parameter because the user will quite often has to run this on different years.
 
For a parameter:

Code:
insert into [sometable]
select field1, field2, field3
from [someothertable]
where [someothertable].[year] = [Enter Year:]


If you are only looking for one year's worth of records, then only records where Year = 'year entered' will be returned. Therefore, the value inserted to Year will always be equal to [Enter Year:] anyway. So I think you only need the parameter.

Hope this helps,

Alex



A wise man once said
"The only thing normal about database guys is their tables".
 
Alex, your helping I'm just not explaining good enough. The records I want to move from are not identfied via a year field, only as a set of records.

So far my query looks like:

INSERT INTO F65 ( localunitcd, countycd, localunittype, [Unit Name], [Year] )
SELECT tbl_Missing_Units.LocalUnitCd, tbl_Missing_Units.CountyCd, tbl_Missing_Units.LocalUnitType, tbl_Missing_Units.Name, [enter year] AS [year]
FROM tbl_Missing_Units;
 
I see. So no matter what year all these records are from (I assume you are only doing one year's worth at a time?), you want to assign a year that is entered by the user?

If so, your query as written should work, I would get rid of the 'AS [year]' though, as it is not really necessary.

Am I missing something here?

Alex

A wise man once said
"The only thing normal about database guys is their tables".
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top