Create Autonumber Field In Access Make Table Query







How to Add/Create Primary Key Programmatically to a Make Table Query in ACCESS 2010/SQL? Team, I need to Programmatically Set the Primary Key of a ACCESS 2010 table. Find out how to get great answers FAQ219-2884. Do i need to write my own? Ideally, I'd just like to create a field in the Access designer as "Autonum: CreateAutoNumber()" Edit: If it can't be done in the query itself, I can also run a procedure afterward. It calls that object's NewRow method to make a new row for the table. Select MS Access Database: Then select the database you want to use: Then, using the Query Wizard, click on the > sign to select the fields you want: Then, the Query Wizard will let you filter any fields, or just click Next: You can change the sort order, or just click Next:. To create an update query that updates the new field in the referenced table to the new AutoNumber field of the main table, follow these steps. These same principals can be used to create reports that show all orders for each product type, or any other combination of Data as long as both tables have a field. The table structure is the same as my previous email. You can manually join two tables by dragging a field from one table's field list to the matching field in the other table's field list, as shown in figure. This prevents you having to redo the design. Check the box that says "Enforce Referential Integrity". In this field, create a DSUM() expression as follows:. However, no other field properties are. To create Query in Access VBA, you can directly write a SQL statement in Access VBA, and then create a Query using the SQL statement with CreateQueryDef Method. It is a convenient way to create temporary tables that are subsets or supersets of other tables. If you are using Oracle 12c onward, you should consider one of the following options. Return to Design View and click on the Show Table button (near the middle of the Ribbon). Enter a half a dozen records. Code Line: " ALTER TABLE [TABLE1] ALTER COLUMN. Name the first column. Add Auto number in Access Query Step 1 - Create User Defined Function. Let us now add some more fields by clicking. I need to create an Autonumber field in a query I am currently running. You must tell Access that this is a trusted database before it will accept a data-definition query. This question came up during an Access class: How do I set it up so that the AutoNumbers are all 4 digits? The answer is very simple. We'll teach you exactly what a parameter query is and how you can create them. That means, if you need the resulting table to have an Autonumber. This can be useful when you need to create a unique number to act as a primary key. Luke has written and presented a wide range of topics related to Access over the years. com Blogger 51 1 25 tag:blogger. MS Access Create Table. It is not actually stored in the database tables. Make the changes, then save and close the file. When you create a query, there are several ways to add fields to the design grid. on the above table. You can press and hold the Ctrl key on your keyboard to select more than one table. Type this SQL statement in the SQL query design window: CREATE TABLE Personnel (. Is there some fast way in a macro to delete all records in a table. com,1999:blog. Question: In Design View, Create A Table Named Customers. We now have our employee ID field with the caption Employee ID. This is the part that most of us get confused with because Access relationships (as any other relationships) can get quite complicated. When I run the Pull Support Cases qry, I manually select the Pk field. To sort the output of a SQL query, use the key word aAC 439. Whenever you want a query to ask for input each time you run the query, you create what's called a parameter query in Access 2013. 2) once it is pulling the data you need, change it to a create table query, name it what you want the new lookup table to be. Put the name of the AutoNumber field into the LinkMasterFields and LinkChildFields properties of the subform. Access can create and save Import Specification Files for importing external text files into tables. This prevents you having to redo the design. It sets values for all of the record's fields except the AutoNumber field StudentID. Although the naming convention is nowadays often used within the Microsoft Access community, and is the standard in Visual Basic programming, it is not widely used elsewhere. Creating a GUID primary key column in Access, SQL Server Desktop (MSDE), or SQL Server is very similar: Launch your database system and create a new table. You need a number field that contains the rank numbers. MS Access>> create tab >> Query Design >> It should popup for choosing table, please click "close" button & click on "SQL" from left top corner below File menu. Furthermore, you can only create a new table with a structure based on that of an existing table. This is a simple query that sums Debit. Select the Create tab and in the Queries group click Query Design button. Example: Make-Table Query. Microsoft Access: "Make-Table Query" Force Memo Fields by SLeepdepD on Oct. An AutoNumber field may be matched with a Number field if the. On the Create table page, in the Source section, select Empty table. Add the second field, if you need to. Access displays the defaults before you save a record. Just follow these steps to create a simple query: Display the Create tab on the Ribbon. Working with Queries and Reports • To Create a Select Query: Click the Create tab on the Ribbon and click the Query Wizard button in the Queries group. The Primary Key is the best Field because it is unique: it is an AutoNumber that is Indexed (no duplicates). For example I want the name and last name from the Emp table, but I want that the first field is an autonumber that identifies the record so the results of the query should look something like. Otherwise you will get the:. On the Create table page, in the Destination section: For Dataset name, choose the appropriate dataset. Table constructor is a fast and simple way of creating tables in DAX if you need. WordArounds for Access' AutoNumber data type. Thus, we ran a Pass-Through query for each table. The foreign key can be used to cross-reference tables. In each table, double-click the field or fields that you want to use in your query. When you try to run the query you may find you have trouble appending into an AutoNumber field, especially if it is your primary key field for that specific table. Creating a GUID primary key column in Access, SQL Server Desktop (MSDE), or SQL Server is very similar: Launch your database system and create a new table. A foreign key is a field in a relational table that matches the primary key column of another table. NET Cookbook [Book]. For now, suffice it to say that the aforementioned AutoNumber field is a field that contains an automatically generated number so that each record is unique in that it has a unique AutoNumber, or ID. Base an append query on the single. This prevents you having to redo the design. 28 Chapter 3 Creating Basic Reports with the SAP Query Tool 12. Step 1 - View records. Make Table: Create AutoNumber Field Feb 19, 2007. Run the Query, now the auto number is generated in. Have a query to empty the table, Then use your query to add records to the table. Create the join by click-holding on the PLAYER_ID field name in one of the tables and. The Access Screen On entering Access you are presented with a blank screen, apart from the menus, toolbar and Getting Started Task Pane (on the right). The more efficient way is to use queries to calculate the values "on-the-fly. We will now use Design View to do two things: Create a new table; Set field properties for our existing table; Create a new Table in Design View. We now have our employee ID field with the caption Employee ID. 1 Problem You use AutoNumber fields in your tables to ensure that you have unique values for your key fields, but a key based on an auto-incrementing Long Integer AutoNumber field doesn't sort your tables in a useful order. AutoNumber fields can be (and often are) used in referential lookups - an idea that would be disastrous with xBase record numbers. In Access, it is common to define a Primary Key field in each table, usually as a field that is of AutoNumber data type, to serve as the PK. field, you have to create the table ahead of time and change the. In the Show Table dialog box, double-click the tables from which you want to retrieve data. Then select the field Amount and change the sort order to descending. Working with Multiple Tables in a Query With a properly constructed relational database model, you'll end up with fields that don't make much sense by themselves. Start Access. To do this, right-click in the field and select Rename Field. Detail section: The section of a form or report that displays the records from the underlying table or query. When you try to run the query you may find you have trouble appending into an AutoNumber field, especially if it is your primary key field for that specific table. Access Queries What is a Query? A query is an Access object used to view, analyze, or modify data. The syntax is not really spoken of in the Access Help files, but it goes a lil' somethin like this:. The query will then add the rest of the double quotes as in the figure above. In this lesson, you will learn how to create a simple one-table query. either modify the default style for a table or create a. Press ALT + F11 > insert a Module > copy and below and paste to Step 2 – Add Expression in Query. Use the CREATE TABLE statement to define a new table and its fields and field constraints. If your table has no relationships to other tables, use either Method 1 or Method 2 to reset an AutoNumber field value. Adding Prefix to AutoNumber. AutoNumber is a special field type in Access. com,1999:blog. Make-table queries are most useful for providing backup snapshots or for creating tables with rolled-up totals at the end of an accounting period. Working with Queries from the table down to To Create a Select Query: Click the Create tab on the Ribbon and click the Query Wizard button in the Other group. Create a make table query On the Create tab, in the Queries group, click Query Design. A query retrieves data from an Access database. These can work well with comma separated lists or regular fixed width lists of data. Creating an. on the above table. The matching field in CUST and ORD is CustNum. This is done with the 'posts_where' filter, and we'll use the idea that whatever WordPress did to search the post title field, we'll do the same thing with our custom table fields (rather than trying to duplicate WordPress's rather complex logic). An append query that adds new records to this table. Creating a qualified table in a database is everything. However, when creating a calculated column in a table, the available functions are very limited. You can create date tables in SQL, DAX, M, and many other programming languages. Repeat this process for each table -- text file -- you want to add. I have a Maketable query in an Access db that could use an Autonumber field. Create a query which filters the records of a table. Getting an AutoNumber Value from Microsoft Access Problem If you add a row into a Microsoft Access table that has an AutoNumber column, the value assigned to the column … - Selection from ADO. The SQL engine will provide the two sums and the average per each existing combination of the remaining three fields. Now, let's use these tables to create a query. Create a query with the Transaction table as the source, and add the Debits field. How to Create an Append Query in MS Access This article addresses the importance of Append Query and the proper way of creating them in MS Access. The Excel worksheet we have with student data has all the same fields as the Access table. Don't worry if that doesn't make a bit of sense right now. In order to work effectively in Microsoft Access, you need to know how to create tables and define appropriate fields for your data. You can get it to create a new table based on criteria and save it either in the current database or add it to another Access database. Row Number in a Query Adding a Row Number in your Query. This done by following the Option Group Wizard. Relating Tables in a Database : Tables are related by Key Data. Click the right mouse button on the query and then choose Run Statement from the context menu. This tip will explain about adding a prefix to an autonumber field. In Datasheet view (Datasheet view: A window that displays data from a table, form, query, view, or stored procedure in a row-and-column format. The proper way, then, is to create your own function that creates the number sequence you need. Step 1 - View records. When you enter a record in the remaining table, Microsoft Access uses an AutoNumber field value one (1. Now the fun begins. A string of text (the source file) can be chopped up (i. One requires you to run a SQL DDL "Create Table" statement, and the other uses VBA to append dbAutoIncrField flag to a new field's Attributes property. It must not be an AutoNumber field (I almost always use an AutoNumber field for my Primary Key field) because you can't edit this type of field. In your query results, you might want to display the translated value rather than the code (for example, Active instead of A). In this tutorial, we will teach you how to create an update query in Access. Then, we'll learn how to view printed reports. Creating a multi-table query. Click No to stop the procedure (no table will be created). ) Change the select query to an Append query. A foreign key is a field in a relational table that matches the primary key column of another table. SQL - Create a SQL Table. In the Tables tab, on the Show Table dialog box, double-click the tblEmployees table and then close the dialog box. Create Tables in Access - Tutorial: A picture of a table in Design View in Access, showing field names, data types, and a primary key. by Matt Allington In this post, I am going to show you how simple it is to create a custom calendar using Power Query. Click Simple Query Wizard and click OK. How can I create a new table in a Microsoft Access database and import data to it using Matlab? key of type autonumber, the syntax of the CREATE TABLE query. A dialog asks for the name of the table to which you will append records. 7 Create and Use Flexible AutoNumber Fields 6. EasyQuery WinForms is designed to help you with this task. When input tables are from a file geodatabase, tables generally join in the order listed in the Input Tables parameter. This prevents you having to redo the design. It's good for ID numbers and for primary keys, which, as we learnt earlier, need to be unique. We now have our employee ID field with the caption Employee ID. Make Table) query and then change the Select Into query to either an Update or Append Query. It's a very useful practice that we sometimes need to store unique data across multiple columns in a table. Select MS Access Database: Then select the database you want to use: Then, using the Query Wizard, click on the > sign to select the fields you want: Then, the Query Wizard will let you filter any fields, or just click Next: You can change the sort order, or just click Next:. It calls that object's NewRow method to make a new row for the table. Change the name of this field to EmployeeID to make it more specific to this table. However, related fields must have the same data type. Copy the structure of the main table and then create a new table. Create a form from query InvoiceQuery; Create a form from query InvoiceDetailsQuery; Attach the InvoiceDetails form as a subform in the Invoice form; Add all Totals calculations to the Invoice form; step 1 - create the invoice query Create a query in Design mode using all the tables shown. You also have the option of saving your query. In SQL, to create and name a computed field, use the key word AC 438. If it is, you will need to omit this field from the append operation (access needs to create these values automatically - even when appending). For example I want to have a list and when a user wants to add a new value, it automatically generates a new autonumber. Add Auto number in Access Query Step 1 - Create User Defined Function. Relating Tables in a Database : Tables are related by Key Data. The Add Field button allows you to add expected field(s) so you can complete the Make Query Table dialog box and continue to build your model. This prevents you having to redo the design. Add the second field, if you need to. However, when creating a calculated column in a table, the available functions are very limited. This can be useful when you need to create a unique number to act as a primary key. We now have our employee ID field with the caption Employee ID. You can also follow these same steps to import other data tables into Access, such as dbf files or txt files, with some minor variation. ColdFusion Tutorial: Part I Article. NET application get an end-user-oriented query builder which helps your users to run any queries they can imagine without any additional assistance from your support team. See the complete profile on LinkedIn and discover Cory’s. Create a new table in Design view. Set its FieldSize property to Long Integer and give it the same name as the AutoNumber field in the table whose value you want to change. Finally, I'll have a few comments on how you could actually print reports on your laser printer (don't get too excited though, its expensive). I want to know if it's possible to create a form that has read/write access to a very specific (filtered) record set of a table. The two options for creating a Query are Query Design and Query Wizard. In Microsoft Access tables, the AutoNumber field type allows you to assign a unique sequential number to each row in a table. I've prevented the debugger from stopping to the particular exception and trying to run the test in debug mode all the way up to the point where the caller receives the exception (instead of a normal re. Find out how to get great answers FAQ219-2884. i tried to insert a new record. The more efficient way is to use queries to calculate the values "on-the-fly. However, when using the import spec subsequently the table appears correct, but it ismissing the Autonumbered ID field. At this stage, we have created a Make-Table query that will: take all of the fields from the GeogTract table, add a concatenated ID number field, and will turn this into a new table called GeogTractNew. You can also use this query to combine the data from one or more tables into a single table, or to send new tables to different Access databases. If NOT NULL is specified for a field, new records are required to have valid data in that field. Table: T_AFPTracking. Make Table Query A Make Table Query creates a new table in your database based on the results of a query. On the Combo Box Wizard dialog box, Click “I want the combo box to look up the values in a table or query. How can I make this happen?. Using MS Access to create a Running Total or a Cumulative Sum - Part 1 of 2 Posted on May 4, 2014 | 12 Comments While analysing data, there are many instances when you need to create a running total (also known as a 'Cumulative Sum'). We will now use Design View to do two things: Create a new table; Set field properties for our existing table; Create a new Table in Design View. Use lookup drop down lists for text fields, which store the "long integer" auto number of the lookup table. In the form, click Auto-Number/System > Auto-Numbe r to reveal the Display Format section of the form. For now, suffice it to say that the aforementioned AutoNumber field is a field that contains an automatically generated number so that each record is unique in that it has a unique AutoNumber, or ID. Make the SalesRepID the Primary Key field. Also you can create an autonumber in the same manner as an autonumber field in a table. The caption for this field needs to be Item Number. Of course, I modified it slightly to make it more readable and included two buttons on. Duane MS Access MVP Ask a great question, get a great answer. To add a new record to the Students table, the program finds the table's DataTable object on the DataSet. You can get it to create a new table based on criteria and save it either in the current database or add it to another Access. Run the Query, now the auto number is generated in. Step 1: Create a query. How to create a composite unique index (not as a primary key) in MS Access This article applies to Microsoft Office Access 2003 and above. This new table will serve as a practice table and we will begin to populate this table with some data which we can then manipulate as more SQL Query commands are introduced. The other quasi-record number in Access is the number displayed in the bottom left of an open table, query, or form window, such as "Record 12 of 574". i deleted all the testing data in the table. MS Access 2003: Create a sequential number that you can control instead of using an AutoNumber field. In Microsoft Access tables, the AutoNumber field type allows you to assign a unique sequential number to each row in a table. It calls that object's NewRow method to make a new row for the table. In this tutorial, we will teach you how to create an update query in Access. If a query is specified, the Microsoft Access database engine appends records to any and all tables specified by the query. If you would like to follow along, you'll need to download our Access 2016 sample database. Creating Fields, by Data Type Methods of creating fields in Access. Apply any sorting and criteria (This one includes a parameter. In the Tables tab, on the Show Table dialog box, double-click the tblEmployees table and then close the dialog box. Create the first table that contains the counter type field that you want to start on another number. Let's now CREATE a SQL table to help us expand our knowledge of SQL and SQL commands. Once you have run the make table query, check the results. Of course, I modified it slightly to make it more readable and included two buttons on. Below the design grid is the "Field Properties" section where you set the properties of the currently selected field in the table. Create Autonumber in query through MS Access? How do I create a column within a query to add an Autonumber? I don't want the auto number to be in the table, only in the query (as the table doesn't have a unique identifier). Put the name of the AutoNumber field into the LinkMasterFields and LinkChildFields properties of the subform. Parameter Queries in Microsoft Access 2013. We just use all of our tables to a SQL Server database and are looking to continue using MS Access as a frontend tool because of the UI. How to create a 5 digit auto number using Microsoft Access? Ok I'm using Microsoft Office Access 2007 to create a database, I have loads of tables, and for each of those tables i have a field such as Student ID using the "Data Type" auto-number. Create two queries: A delete query that deletes all records from this table. A common Access query is the Select Query. Method 1 : Move the data to a new table using a Make-Table query You can reset an AutoNumber field value by using a Make-Table query to create a new table that has the same data and then adding a new AutoNumber field. However, when using the import spec subsequently the table appears correct, but it ismissing the Autonumbered ID field. An Autonumber field is a special type of field in Microsoft Access. Use lookup drop down lists for text fields, which store the "long integer" auto number of the lookup table. Microsoft Access: "Make-Table Query" Force Memo Fields by SLeepdepD on Oct. Fixing AutoNumbers when Access assigns negatives or duplicates In Access 2000 and later, an AutoNumber field may begin assigning extreme values, negatives, and even duplicates. Once the table / tables are in place you can insert the fields necessary for your query. MySQL will generate a unique number by incrementing the last number of the table and will automatically add to the auto incremented field. Append Query. Author(s) Dev Ashish & Alden Streeter (Q) Can I change the starting value of a counter type field? (A) Yes, you can. We cannot just use the auto-number data type because there is no promise of sequentiality but only uniqueness. , where the months are represented by columns. Microsoft Access provides a means of easily creating a group of radio buttons. WhenI created the import specification I called for Access to and an autonumber field. A foreign key is a field in a relational table that matches the primary key column of another table. Name of the field is its identity and thus it should give a fair idea about the field’s purpose and data type. Create a query which filters the records of a table. Repeat this process for each table -- text file -- you want to add. Optionally, add any expressions to. Link the "Supplier_No" fields of the two tables if there is not already a relation of this type. In a similar fashion, connect the SalID field between ORD and SREP. Furthermore, you can only create a new table with a structure based on that of an existing table. This document uses some standard database terminology, referring to columns as fields. Microsoft Access Tip: Creating an AutoNumber Field Starting with a Number Greater than 1. So the relationship between query and table is only for telling Access that the field is connected,. Code Line: " ALTER TABLE [TABLE1] ALTER COLUMN. ) The trick of holding down the CTRL key to select multiple files doesn't work here. Follow the instructions to select the fields you want to use from the desired tables and create the query. Append Query. When you try to run the query you may find you have trouble appending into an AutoNumber field, especially if it is your primary key field for that specific table. Access with highlight the field name for you to rename it. A table contains rows (or records) of data, and each row is organized into a finite number of columns (or fields). in that i created the invoiceno field as autonumber. We can use case examples or iff statements but it would be much easier to create a lookup table and let access do the calculation. A table contains rows (or records) of data, and each row is organized into a finite number of columns (or fields). Name of the field is its identity and thus it should give a fair idea about the field’s purpose and data type. Insert query in msAccess with autonumber. When I run the Pull Support Cases qry, I manually select the Pk field. Code Line: " ALTER TABLE [TABLE1] ALTER COLUMN. It calls that object's NewRow method to make a new row for the table. Click the Basic List button from the Application toolbar to create an SAP basic list query. When you create an AutoNumber field, the values are unique integers that start with the number 1 and incremented by 1. I use a pass through query as a front end to a "make table query". Additionally, queries allow you to join two or more related tables, concatenate text fields, summarize data, create calculated fields, and append, update, or delete. From the Games table, add the GameName and Rating fields (in that order). It is quite easy to do this in Excel, but I haven't figured out why it is harder than hell trying to subtotal crap and create customized autonumbers in Access. You would normally have a sequence number in the table where you store the results. The code below is what kind-of works, it just erases what's already in the query. This is automatically set to auto number so we don't really need to change the data type. How to Create Action Queries in Microsoft Access. We'll teach you exactly what a parameter query is and how you can create them. Create a query with the Transaction table as the source, and add the Debits field. Save the query using the title Ratings and close the query. At the moment, I'm writing a test that will cause a WCF service to throw an exception on purpose. Just follow these steps to create a simple query: Display the Create tab on the Ribbon. parsed) in order to populate a number of different fields within a record (in the destination table). Most rely on creating an append query to modify the field. Make Table: Create AutoNumber Field Feb 19, 2007. Choose the tables to include in the query; Choose the fields to include, and adjust the criteria; Click the Run button (or just switch to Datasheet view) The results of the query will be displayed. Table constructor is a fast and simple way of creating tables in DAX if you need. Method 1 : Move the data to a new table using a Make-Table query You can reset an AutoNumber field value by using a Make-Table query to create a new table that has the same data and then adding a new AutoNumber field. I need to make a command button that will automatically add +1 to the previous order number. Name of the field is its identity and thus it should give a fair idea about the field’s purpose and data type. Click the Query Design button in the Other group. You can manually join two tables by dragging a field from one table's field list to the matching field in the other table's field list, as shown in figure. " This ensures if the underlying data changes (e. If this is run via a macro, you can run one action after the other. To create a query using the Query Wizard, tap or click ____ on the ribbon and then click the Query Wizard button. This is automatically set to auto number so we don't really need to change the data type. Create a table called tbl_lookup_frequency, with three fields UniqueID (autonumber)words (text) and NumberDays(number). Microsoft Access Tip: Creating an AutoNumber Field Starting with a Number Greater than 1. com wrote: I want to create a query that the first field should be an autonumber. Add the field name SystemID and select AutoNumber as the Data Type. In the Navigation Pane, right-click the table to which you want to add the primary key, and click Design View. Table constructor is a fast and simple way of creating tables in DAX if you need. See Table 1 for a list of the fields included in the query. When you try to run the query you may find you have trouble appending into an AutoNumber field, especially if it is your primary key field for that specific table. The Add Field button allows you to add expected field(s) so you can complete the Make Query Table dialog box and continue to build your model. Method 1 : Move the data to a new table using a Make-Table query You can reset an AutoNumber field value by using a Make-Table query to create a new table that has the same data and then adding a new AutoNumber field. I know I can manually set the primary key in my newly-created table, and then run the delete query, but is there a way to produce the primary key in the process of creating the table? In other words, can I set up the make-table query so that the resultant table has the ID number as the primary key automatically?. MS Access allows 64 character limit to the field names which should only contain letters, numbers, and spaces. Find out how to get great answers FAQ219-2884. Name the first column. If your destination table contains a primary key, make sure you append unique, non- Null values to the primary key field or fields; if you do not. On the right side of the window, in the details panel, click Create table. First run the delete query, then the append query. month ) ) && ( !empty( $wp_locale->weekday ) ) ) { $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); $datemonth_abbrev = $wp_locale->get_month_abbrev. Create a form from query InvoiceQuery; Create a form from query InvoiceDetailsQuery; Attach the InvoiceDetails form as a subform in the Invoice form; Add all Totals calculations to the Invoice form; step 1 - create the invoice query Create a query in Design mode using all the tables shown. 1) create the query as a select query and get it pulling the exact data you need in the new table EXCEPT, forget about the auto number for a moment. In this illustration, all of the fields in the table are selected but you can select as many or as few as necessary. To launch, select Tools\Databases Utilities\Linked Table Manager from the menu bar in Access. MS Access 2003: Create a sequential number that you can control instead of using an AutoNumber field. The problem is, the column names are not exactly the same as the field names in our Access table. Sometimes, however, you will have to manually join two tables in the query design window. The more efficient way is to use queries to calculate the values "on-the-fly. Repeat this process for each table -- text file -- you want to add. "How to build a table by extracting some fields from a main database…" I interpret it as: "Query a main database (mainframe) and create a local table. Hope this helps. ” Click Next. If you can join the two tables on some common field or combination of fields, you can use an update query to update a field in one table based on the values found in a second table. Tom Fragale - The. parsed) in order to populate a number of different fields within a record (in the destination table). Make Table Query A Make Table Query creates a new table in your database based on the results of a query.