Access data type conversion - ms-access

I am reworking and expanding a somewhat complex database schema that has a small number of tables and queries but they are closely related. The only problem I had with it was that in one of the tables the 2 fields that were relating to another table were using the field name of the record and not the ID of the record.
I changed the referring fields data type from text to number and entered some data. The queries and the reports work fine with 1 exception:
There is one report that uses both referring fields. One of the fields is ok but the other one shows symbols instead of numbers. ( The IDs in my sample entries were 14 and 20 and the symbols shown were a double barred music note /alt code 14/ and the symbol for an end of a paragraph /alt code 20/ ) Investigating further I have found that if I make a query that contains the query source for the report both fields display fine, but if I add another table to that query the second field once again shows symbols instead of numbers.
I have found a workaround of this by converting those fields back to text and the id fields in the other tables to text as well. This text key will probably haunt me later on, so I'd like to make it right before it is too late.
This is all access 2010 btw. The source file was already in 2010 (couldn't open in 2007 even)

Sounds like a corruption issue for sure. I would try adding a new column and run an update query to populate it with the values from the old column (maybe use cint(indexfield)), then delete the old column.
It might also be a good idea to decompile the database. This often helps resolve corruption issues.

Related

MS Access Data Entry Validation

I've been tasked with creating a database to help with my company's annual physical inventory count. We have an ERP system that contains all our part numbers, and all of our part numbers come in boxes that have a carton label containing "part number" and "quantity" which are both barcoded. We are trying to switch to a system in which we scan all the boxes into my access database vs. our previous system of physically counting and writing tags. So far everything works great, the only issue is that some bar codes get damaged or just won't scan properly for some reason, so the scanners read the barcode as a part number that doesn't exist. We are able to export a list of all part numbers from our ERP system into an excel file which i have linked to my database that we use to see which part numbers were entered that don't exist in the system. My question is, is there a way to prevent people from scanning part numbers that don't match any part number in the excel file exported from our ERP system? I'm using ms access 2003
Using a combobox with LimitToList property set to yes is a great solution. Just to let you know that with this solution it is still possible to PASTE values that are NOT on the list. If you want to guarantee that it is not possible that the field contains wrong values, the best is that you create a Relationship (with referential integrity) taking the Table field containing all valid part numbers as the master field, and the one taking the scanned value as the slave field.

Sorting error in one field of Report

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.

Complex fill in the blanks query in MS Access 2010

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;

#NAME in Access report expression

I have an Access 2007 report which has a table as a data source. I have a few columns of data that directly pull data from the table in a summarized way (using report groups) and the last column is the total of the first 6 columns. Simple enough.
Now the expression that calculates the sum of those 6 columns sometimes returns #NAME? and sometimes does not. I have more than triple-checked for any error, typo, whatever.
There is no space in front of my expression;
The expression does start with an =;
The references to columns in the table are all valid;
No control has a name even remotely similar to any column in the source table;
I have tried generating the expression using the expression builder;
There is no conditional formatting tied to any control;
There is no VBA code used at all in generating the report.
Also, sometimes if I copy the one of the boxes with #NAME?, delete it and paste it back then all the #NAME? errors disappear. Then I save and reopen the report and the errors are back.
I'm out of ideas for this. I can't post screenshots or distribute the file due to its nature.
Thanks !
I had similar problems...The solution was that I have used unicode characters in Names. For example a Text Box with the control source "dataščž" had the Name "datačšž". This was working in previous versions of Access, but not anymore. Changing the Name "datacsz" solved the problem.

ACCESS: Truncation error when appending CSV data to tables?

I am currently experiencing difficulties when trying to append data to existing tables.
I have about 100 CSV files that I would like to create a single table from; all the tables have different column structures but this isn't really an issue as the associated field names are in the first row of each file.
First, I create a new table from one of the files indicating that my field names are in the first row. I change the particular fields that have more than 256 characters to memo fields and import the data.
I then add to the table the fields that are missing.
Now, when I try to append more data, I again select that my field names are in the first row, but now I receive a truncation error for data that is destined for the memo fields.
Why is this error occurring? Is there a workaround for this?
edit
Here is an update regarding what I've attempted to solve the problem:
Importing and appending tables will not work unless they have the exact same structure. Moreover, you cannot create a Master table with all fields and properties set, then append all tables to the master. You still receive truncation errors.
I took CodeSlave's advice and attempted to upload the table, set the fields that I needed to be Memo fields, and then append the table. This worked, but again, the memo fields are not necessarily in the same order in every data file, and I have 1200 data files to import into 24 tables. Importing the data table by table is just NOT an option for this many tables.
I expect what you are experiencing is a mismatch between the source file (CSV) and the destination table (MS Access).
MS Access will make some guesses about what the field types are in you CSV file when you are doing the import. However, it's not perfect. Maybe it's seeing a string as a memo or float as a real. It's impossible for me to know without seeing the data.
What I would normally do, is:
Import the second CSV into it's own (temporary) table
Clean up the second table
Then use an SQL query to append those records from the second table to the first table.
Delete the second table
(repeat for each CSV file you are loading).
If I knew ahead of time that every CSV file was already identical in structure, I'd be inclined to instead concatenate them all together into one, and only have to do the import/clean-up once.
Had a very similar problem - trying to import a CSV file with large text fields (>255 chars) into an existing table. Declared the fields as memo but were still being truncated.
Solution: start an import to link a table and then click on the Advanced button. Create a link specification which defines the relevant fields as memo fields and then save the link specification. Then cancel the import. Do another import this time the one you want which appends to an existing table. Click on the Advanced button again and select the link specification you just created. Click on finish and the data should be imported correctly without truncation.
I was having this problem, but noticed it always happened to only the first row. So by inserting a blank row in the csv it would import perfectly, then you need to remove the blank row in the Access table.
Cheers,
Grae Hunter
Note: I'm using Office 2010