I am trying to create a community database in Access (2003 preferably). Part of the main table has several fields relating to personal relationships, with field names such as "Partner", Child_LT_16", Child_GT_16", "Parent", "Sibling" etc. On the entry form each of these fieldu can have a number entered for the number of each kind of relation. Each field is defined as "Integer". The entry and normal display via a form is OK for this basic operation. However I now want to have an additional field to be ised on Forms and Reports that show the total number of relations for each record.
I have constructed a query, with a calculated field of the form
Total_Relations:[Partner]+[Child_LT_16]+[Child_GT_16]+[Parent]+[Sibling]
This query doesn't throw any errors and runs without problems, BUT it doesn't return any value for any record. In all cases the Total_Relations column stays blank (empty).
It is as though the query engine is seeing all the field values as EITHER empty (some are empty others have values usually between 1 and 3, virtually all have a numeriacl value somewhere in the various relations fields) OR taking the field value as text and giving it a NULL value (but the fields are defined as Integers.
I have tried various things including using VAL([Partner]) etc. in case the fields were being taken as Text. In this case any record that had any NULL field threw-up an error message, only records where all relevent fiels had numeric values did not throw the error, but they still did't show a total (or any) value either.
I have tried recreating the query gain, from scratch, several time, but with the same result each time
I have done this type of calculation loads of time before without problem, but this one has me climbing upm the walls.
Any suggestions from anyone?
PLEASE............
In MS Access, if you add two (or more) values together and any one of them is null, then the result is null.
You need to check is each value null, or make the fields not null-able, so there will be zero values in there if nothing is entered.
Have a look at this for working with Nulls in MSAccess, Tip #5 is the one you want
Related
In MS Access 2016 I have a table named Master that periodically needs to gets updated with ‘updated’ data from a table named NewData. Each table has the same fields, except Master has one additional field named OTHER_SOURCES (explained further down). They each have an indexed unique id field named EVENT_ID. I’ve built an update query where the tables are joined one-to-one on the EVENT_ID field. In this query I have the fields in Master getting updated to the new values from the same fields in NewData if the TIMESTAMP field value is different. If the TIMESTAMP values haven’t changed, then those records do not get updated. This part is pretty straightforward and works fine.
However, I have end users that may make occasional changes to the values in the SIZE field of Master that need to be preserved and not overwritten with updated values from NEW_DATA. When a user makes a change in SIZE field, he documents the change with information obtained from other sources, which is stored in the extra field I mentioned earlier: OTHER_SOURCES. Here’s what I need to do, and I just can’t figure it out. Whenever a user has made a change to the SIZE field for a record, I need the update query to not override that value in the SIZE field, but still update the values in all the other fields (again, assuming the TIMESTAMP values are different between the two tables). It seems I need to use an IIF statement, but I’m thinking it needs to be done in VBA where I’m a bit of a hack. See screenshots. I greatly appreciate any help you can offer.
enter image description here
enter image description here
You can still proceed with the update, but update it to the same value as its previous value:
SET SIZE= IIF(nz(OTHER_SOURCES,'')<>'', MASTER.Size, NEW_DATA.Size)
This assumes that anything present in the MASTER.OTHER_SOURCES column indicates that the user has changed MASTER.Size. Note that MASTER.Size will never be updated from NEW_DATA.Size until someone (end user) removes MASTER.OTHER_SOURCES.
I have encounter an odd problem with a specific field which has the Field Name: Billing and is Datatype: Short Text. When I try to sort alphabetically the result on the Report is actually based on a corresponding field that is datatype Autonumber and also serves as the tables primary key.
All other fields in the report sort just fine.
I would like to think I have tried the usual corrections, but may have missed one and I am hoping someone can point this out if that is the case.
Generally I would go into design view of the report, select the field on the Report, click the 'Group & Sort' button on the ribbon and make my selection for how I want to sort from there.
How I know that it is the Autonumber field that is being sorted is that when I switch from A-Z to Z-A, the top result when Z-A is in fact the final entry in the table and concurrently the highest number in the Autonumber and primary key field.
I cannot see how these two fields are linked or why the Billing field is sorting based on the Autonumber field. I have removed the primary key and still encountered the same problem.
A final note that may help point me in the right direction. When I go to the table that holds the field in question I've noticed on Datasheet View there is no option to sort this field. All other fields have the option to sort by clicking the black triangle, but this field does not have this option. I believe the sorting does take place on the Report, but I found it odd that all the other fields could be sorted in Datasheet View, but not this field. Any help is greatly appreciated. Thanks
UPDATE
So a (hopefully) short update to this situation. The solution I undertook was as follows.
Exported the table with the sorting problem to excel. From there undertook the process of duplicating the table with no data in it and then ran an append query to put the data back into the table.
This worked! … kind of.
I had suspected since I began trying to fix this issue that the sort was being affected by the primary key number. I feel this has been confirmed, but it has created a new issue.
What has occurred now is that a relationship query no longer functions because the fields are no longer the same type. One field is an autonumber primary key while the other field is short text. I can only conclude that the field prior to the excel export/import was data type number, even though the data within the field was all text and no numbers. But, it was necessary to have this field as a number so that the relationship to the autonumber field in the other table would function.
Overall it is a small victory in that the report that I first noticed the error on, the error being it would not sort in proper alphabetical order, is now sorting properly. This is an important report that is used often so I needed to get it working properly to move things forward. Unfortunately I have now entirely lost the use of a different report because of a ‘Type mismatch in expression’ which I am concluding is the autonumber to short text relationship.
So I am going to post a new question about relationships and datatypes to see if there is someone that can assist in getting this fully functioning again. I hope this helps others who have encountered this problem.
I have a large data set that holds the names and addresses of our customers. I need to allow the user to search this data set, however the user rarely has the key field necessary to make the search easy. They do however have three key values that will get them a reasonable subset to work with. They have the customer's last name, street and zip code. While this does not assure a single match, for the most part I should be in the less than 10 returns range. I am guessing most will only return 1 value.
I would like to have the user submit multiple lines of the three values and then return the appropriate values to user. I am looking at putting a new value in my table that has the three values concatenated, but I would have approximately 19 MM rows of data affected. I was wondering if there was some way with SSRS to submit an array variable with the three fields and then return multiple lines based on the values?
I am using SQL Server 2012 as the database.
Yes like BishNabo wrote, In your SQL just add the below structure with your field and table names. I've wrapped #var in wildcards to allow for partial values. This format requires all three to be submitted by the user.
Where tbl.fld_LName LIKE '%#LastName%' and tbl.fld_StreetName LIKE '%#Street%' and tbl.fld_ZipCode LIKE '%#Zip%'
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d6952bd0-af17-403f-8402-02759a9517fb/execute-tsql-on-ssrs-2012-with-3-parameters?forum=transactsql
I'm brand new to Access 2010, well to Access in general. I have a query that returns 10 columns (the query is called pending_review, the source is a table called escalations) in the results, some of those fields are blank since they have to be reviewed. One of the resulting columns is the primary key.
So this is my problem: I need a to create a form where I can type the primary key and the fields on the form will populate with the info from that row so I can fill the blank spaces with information that I now have and then update the table.Once the table is updated, that row should no longer show on the query results.
What I have done is that I created the form, but I don't know how to do the part of typing the primary key and everything gets populated. A solution would be to make a combo box that shows me the primary keys of the rows in the query results, so that every time i edit something in one of those fields for the query to be run again and reduce the number of options in the combo box.
Question is, how do i do that? or is there an easier and better way to do it?
Thanks in advance!!
Can you not just create a new form using the pending_review query as a data source? Access makes it very easy--you can just use the form wizard. This gives you a form in which you can edit one row at a time. Presumably the pending_review query has a filter condition that checks for certain fields being blank (null) or not. If you finish editing a result row in the form, and refresh the form, the row should then disappear from the form because it will no longer be returned by the pending_review source query.
Even if you need to do something more complex, this should at least be a good start.
I have two tables and from that I am generating a query. I have columns in my query with field type yes/no. These are basically columns to determine the race of a person. The user enters information in yes/no for various races. I want another calculated column in the query which checks for all other race columns and calculates values in it.
I have to check for a few conditions in for the values in columns
For example:
1) If Hispanic is chosen, the new column should say hispanic(no matter what other options are selected. This is like a trump card)
2) If more than one is selected, then new column entry should say "multi"
3) If none of the options are selected, it should say "unknown"
4) If exactly one of them is selected, then that race should be displayed
Can anyone help me with this? I am new to Access
I can't code it for you but I can point you in the right direction. What you want to do is take all the tests you explained above and put them in a coded format :
iif ( condition, value_if_true, value_if_false )
Since you have a lot of possible outputs i'd use something like a Case Statement where you can test for all the possibilities.
Follow this link if you need any info on how to code both type of statements (iif and case).
Once you have tried something like this, you can comeback with a specific question if you encountered a problem in the process.
Good luck with your database.