473,385 Members | 1,564 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to filter records in an append query by choosing field in a form

121 100+
I have a function that copies records from a table called ETL to a table called EXPORT then it exports the records in EXPORT as an excel.

The record are all marked as coming from a set of data owners.

What I'm trying to do now, is to filter the records that get copied into the EXPORT table by having the users choose which "DATA_OWNER" they want to export the records for. I would like to have them choose on a form which data owner they want and then have a button on the form which then copies the records to the export table (filtered by the selected data owner) and then exports the spreadsheet.

I can get through the whole process, except for how to get the users to select the field and thenuse that to filter the records taht get copied.

Any help would be greatly appreciated.
Apr 10 '07 #1
4 4270
pks00
280 Expert 100+
What is the code you have now that copies from ETL to EXPORT
Is it just a append query?

If so then u could add filters to that
by doing the copying via code
or creating a temp query and using that

but I need to know what u currently do to perform the copy from ETL to EXPORT
Apr 12 '07 #2
nico5038
3,080 Expert 2GB
You can create an unbound form (not linked to a table) with a combobox showing the distinct DATA_OWNER's. Name this form frmSelectDataOwner and the combobox cmbDataOwner.

Just use as source for the combobox:
select distinct DATA_OWNER from EXPORT

Next create a query named "qryDataOwner" referring to the combobox on the form as a criteria for the DATA_OWNER like:
forms!frmSelectDataOwner!cmbDataOwner
This query will only work when the form is active and a DataOwner has been chosen.

Now add a button to trigger the export to excel with the command:
docmd.transferspreadsheet acExport, "qryDataOwner",....

In the additional parameters the excel version and the target file are set.
When creating the filename just add the combobox value to get an excel sheet "named" like:
"C:\Datasheet_" & me.cmbDataOwner & ".xls"

Getting the idea ?

Nic;o)
Apr 13 '07 #3
JHNielson
121 100+
What is the code you have now that copies from ETL to EXPORT
Is it just a append query?

If so then u could add filters to that
by doing the copying via code
or creating a temp query and using that

but I need to know what u currently do to perform the copy from ETL to EXPORT

The code is just a simple append query - the two tables are nearly identical
Apr 14 '07 #4
NeoPa
32,556 Expert Mod 16PB
I have a function that copies records from a table called ETL to a table called EXPORT then it exports the records in EXPORT as an excel.

The record are all marked as coming from a set of data owners.

What I'm trying to do now, is to filter the records that get copied into the EXPORT table by having the users choose which "DATA_OWNER" they want to export the records for. I would like to have them choose on a form which data owner they want and then have a button on the form which then copies the records to the export table (filtered by the selected data owner) and then exports the spreadsheet.

I can get through the whole process, except for how to get the users to select the field and thenuse that to filter the records taht get copied.

Any help would be greatly appreciated.
In the code behind a button on your form...
  1. Get the SQL out of your current APPEND query.
  2. Update your SQL to include a WHERE clause designed to select the item(s) from your Owners list (ComboBox or Multi-Select ListBox depending on requirements).
  3. Execute the new updated SQL (DoCmd.RunSQL ...).
  4. Execute the TransferSpreadsheet command as before.
Apr 17 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new...
6
by: Ralph2 | last post by:
Some time ago with a lot of help from this group I made a reasonably successful database to keep track of our shop drawings. However the searching mechanism is too complicated for the occasional...
3
by: google | last post by:
This is something I've done plenty of times in '97, but I can't seem to get it to work correctly in Access 2003. Say, for example, I have a form with an unbound combobox, the data source is a...
11
by: Bob | last post by:
I am in the process of upgrading an Access database to SQL Server (and climbing that learning curve!). The wizard happily upgraded all the tables and I can link to them OK using ODBC. The...
5
by: Ron S | last post by:
After days of searching I finally an example that would work with my application, the only problem is after entering all of the code it is not working. Would someone be kind enough to take a look at...
2
by: jcf378 | last post by:
hi all. I have a form which contains a calculated control ("days") that outputs the # of days between two dates (DateDiff command between the fields and ). However, when I click "Filter by...
2
by: Gareith Stanley | last post by:
Hi again :) I have a form that user enters parameters into which then pops up another form with results filtered by the chosen parameter (field in table) What I'd like to do is order the...
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
1
by: Barb.Richards | last post by:
I have created an append query that pulls information from one database, and will append the selected information into a new table. The fields are setup like 'number' 'category' 'code' 'shares' and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.