I have a query which joins a few tables. The query asks for a parameter when it is run. Then it displays a few columns/fields from its results, the other fields (like, the entered parameter and other fields that are common to all rows) are hidden. I'm trying to create my first Access report based on this query and I'd like to use some of these hidden fields as a record source for text-boxes/labels but I've been unable to do so. Those fields don't appear in the list of possible record sources.
I've tried the Add Existing Fields button and selecting the field I want from Fields in related tables but when the bound textbox shows up in the report with an error like Invalid Control Property. No Such Field in the Field List which I think means the fields are still invisible to the report. Would appreciate any help getting this done.
The answers is to edit the query and include the missing columns so that they are available to the report.
For non-selected query columns, the use of the word "hidden" is misleading. The way that SQL works--even beyond SQL in the overall concept of datasets--is that only subsets of data are requested in a query. If certain columns are not selected in a query, they are plainly and simply NOT available in the resultant dataset.
It may be possible to re-aquire the excluded columns with another query, but that still does not imply that missing columns were just "hidden". In the case of a subsequent query to get different columns of data, the database engine must re-analyze the new query, re-read the data, then compile the data from the new set of columns to be returned in a completely new subset of data. It is a complete round-trip process that is much more involved than just un-hiding the data.
Forms and reports are completely different types of objects that can mark fields as "hidden", but a query is not the same despite being displayed in a datasheet. Objects like Access Forms and Recordset objects in (VBA) code are designed to hold subsets of queried data, so they are able to temporarily hide (or ignore) or un-hide certain fields without re-querying the database. (Technically an Access Form has its own Recordset object for holding and managing queried data.)
Even though Access is "self contained" with both database and user-interface elements, it is still primarily a standard RDBMS (Relational Database Management System). The principle idea in efficient data handling of an RDBMS is to get only what you need for the current operation. Consider that SQL can be used to query data from a remote server. Even Access can get data from and update data on SQL Server, for example. If data fields were only "hidden" when not included in a query, that would imply that the entire database (or at least an entire table) would be passed back and forth, and that the only thing hindering getting at any column would be "making it visible" as though it is actually immediately available. That would be terribly inefficient both for memory and for remote communications.
Related
I have a subform in form which is created from two linked SQL tables. I run the subform from a query. I have 2 left joins in these tables. Then I have multiply expression of two columns, each column from one table. Then I run it, everything works fine, but other can't open the subform. The error code is like this:
Access this expression is typed incorrectly or it is too complex to be evaluated. for example a numeric expression may contain too many complicated elements...
Often this will fail as the database starts to grow as well. Don't be afraid to use those complex queries but just create a static temporary table. It will ultimately be faster (lookup in a table vs multiple query calls) and easily bypass these complex embedded calculation calls.
PS
Sometimes I would create ComplexQueryA, then ComplexQueryB would use that as the datasource and do another calculation etc, but ultimately when my final results were done I would always dump into a static table otherwise the application would be way too slow!
I'm trying to create a small MS Access database to ease up my everyday job. The problem is I'm a noob when it comes to databases. I'm trying to prevent the user from accidentaly updating the wrong record.
I have a table of records, some of which are not 100% complete.
I created a query that lists only these incomplete records.
On a form, the mentioned query is fed into a listbox.
I want the user to be able to pick an incomplete record from this listbox and fill in some of the remaining parts of the record in a bunch of text boxes. What I don't like is that the record gets updated as you fill in the form fields (they're bound to the table) WITHOUT any request for confirmation. If the user picks a wrong record at the start, the records are gonna get messy with every text box filled. Or that's what seems to be happening.
Here's my idea of the user form:
Is there a correct way to do this? I could force it all with VBA but I'd rather avoid that and use a more native (correct) solution.
Thank you for any answers.
Table constraints are an important part of database design. Any grouping of elements that together are required should be in their own table. This way the required fields must be entered for every record in that table.
For each data entry step you will have one or more tables representing the required data of that step.
If you are following database normalization best practices this should be simple to achieve because your data will already be broken down in to small elements that can have required fields to complete each record.
If you have a record that contains fields that are filled out at different steps then that is a design smell that indicates your table is not properly normalized.
In MS-Access, the forms will follow these rules set in the tables. You will not be able to save a record that has required fields missing.
Given I've created an Access Form with a ListBox; property > other > Multi Select = Extended; which permits multiple selections.
User selects multiple items.
Clicks a button that creates a report in "Print Preview"; but this report is based on the query, and the query is based on the values in the form.
This is accomplished by using this in the query when viewing in Access Query Design View (not SQL):
Like ([forms]![padc]![V2])
Where the form name is padc and the value to compare is V2.
Previously, rather than the ListBox that might show 10 options, V2 was just a field with one value. A user would either type a partial value, such as jack*, and the report would pull every instance where this value began with jack; whether that was jack, or jackie, or jacko, or jackson, etc. The LIKE part of this permitted the "fuzzy" logic bringing about varied results. The query would run, and the report would show all the records with anything starting with jack.
My goal, really, is to have a user select one, two or three, or all the available options in this box, and have the report respond correctly.
I believe the ListBox will let me do this, provided I have all the right names in the table that is the source of the options available to choose from.
I set the listbox to "multi-select" to enable multiple selections on the form.
The form is happy. It can let me click/highlight one or several items from the list.
The query is not happy.
For the field V2, neither
Like ([forms]![padc]![V2])
nor
=([forms]![padc]![V2])
Will retrieve records to populate the report; regardless of whether or not just one value in ListBox is selected or multiple values. (Like = fuzzy, and = means exact match.)
Neither work.
Of course, if the query won't perform, then the report won't perform either.
How can I write the correct query in Access, using "Query View = Design View" and or SQL to get this to function properly?
If the answer is "it can't be done without using VBA" then please point me to the VBA solution that a 5-yr old can understand, because I have zero experience using VBA.
Folks have recommended I use VBA; specifically that I should incorporate the "IN() IN function" in some manner; but I don't comprehend this solution at all.
I admit to being ignorant; not stupid; but ignorant.
I have looked and haven't found a method on here to do this. I am assuming my search is skewed and I just missed it, if this is the case, please let me know.
Anywhooo, I have a large and unwieldy report coming out of SAP every day. Because it will often have some strangeness, we import that into an Access database so we can keep an eye on the stuff we need in our department. I am using a combination of 6 fields to create a primary key in Access. The information in those fields is about the only thing consistent I get out of this SAP report, but the remainder of the data can be considered dynamic and can change from day to day. Usually this is a matter of filling in a few blanks, Occasionally this is changing existing data, and on rare occasions, it may involve deleting data out of a handful of fields.
The SAP report is around 130 columns of data, So I'm looking for an efficient way to roll in the changes without overwriting what folks put in there manually.
EDIT:
Here is the way this is used. SAP (for reasons I'm not going to go into) sometimes will have bad data show up in the daily report. We are using Access to track and put the correct data in to something that we can generate much more accurate summaries. What the users put in is to be considered true and accurate.
The transactions we are tracking can take a long time to complete. Most take around 30 days to complete. That's why I will have blank fields on one day, and several of them to be filled in on the next. We might not get any for the next few days and then a bunch more are filled in later. That is the normal flow.
What I have to account for is the odd occasion where a mistake is made early in the process. At a certain point, an error will break SAP's ability to update anything at all in the report we have to use.
I have 3 fields set up that trigger what my users daily work is going to be. There is a logical flow so that user 1 completes what he needs to do and then that record will show up on User 2's report. These fields will also stop the general update process in an exception report if there is a difference in what is coming in from SAP, and what is already in my database.
What I am looking for is some way to systematically fill in blank fields, on existing records in access. I do not want to overwrite if something is in a field, only the null values. I can do this on one field at a time, but each record has about 130 fields. I'm wondering if there is a way I could do this in just 1 query?
Thanks all! I hope the edit makes more sense now
A simple google for "Access SQL update null values" could have yeilded you what you need. But if all you need to do is fill constant values into empty fields then something like:
UPDATE Table SET Table.field1 = VALUE
WHERE Table.field2 is NULL;
Now if this data is different for each record based on; say data from another field, then you may need to write some VBA to build that value/string for you. But otherwise if you are JUST updating null fields to include data, then a simple UPDATE statement will do
EDIT Based on new info:
So if I'm understanding correctly: you have two tables. One table with the blank fields and another table that contains the values you need.
If this is the case, you can use a similar UPDATE statement, but use an inner join to get the data you need from table B to fill in table A
UPDATE TableA INNER JOIN TableB ON TableA.KeyField = TableB.KeyField
SET TableA.NullField = TableB.NotNullField
WHERE TableA.NullField Is NULL;
I'm using MS Access 2007 as a front end and have all linked tables in SQLServer 2008 R2 backend.
In a form in Access I am trying to execute the FIND button either in the ribbon or by creating a button on the form with the expressed purpose of looking for records with a specific value in a particular field.
When I complete the entry in the FIND window, I click on Find Next. In some cases, the record(s) is found immediately. In others, it can go for hours only to report that it can't find anything (when I know it should).
The table I am looking in has approximately 99,000 records in it. It doesn't seem to matter whether or not the field is indexed.
Is there something I'm doing wrong, or is Access unable to handle this? Also, is creating a stored procedure with handling multiple search requests and passing the info to Access the answer?
The find methods are known to be slow with ODBC data sources. Here is what the Access 2007 Recordset.FindFirst Method help topic says:
When working with Microsoft Access database engine-connected ODBC databases and large dynaset-type Recordset objects, you might discover that using the Find methods or using the Sort or Filter property is slow. To improve performance, use SQL queries with customized ORDER BY or WHERE clauses, parameter queries, or QueryDef objects that retrieve specific indexed records.
Futhermore, binding an Access form to a record source of 99K records is a performance challenge. Use a query as the form's record source, and design the query to return only one or a few rows.
Give the user an option to choose a different set of rows, and modify the form's record source property to reflect the user's choice.
This depends on the type of search you need and on the data type of the column (field) to be searched. For example, if I have a text data type in an indexed column and I search using Start of field or Whole field, it will be quite fast, however, if I search for Any part of field, it may well fall over. In other words, if Access can use an index for the search, it will work, even on quite a large table, otherwise, you may be best with a stored procedure, though I doubt that will be fast without an index, either.