How does a user insert a null in MS Access? - ms-access

MS Access appears to support nulls in code, but I can't for the life of me figure out how to enter a null directly in a table. This is maddening because once a field has had a figure entered in it, it can never be deleted/set to null. Normally, allowing zero length strings would take care of this, but Access treats the XML export of a null and a zero length string differently. A null eliminates the associated XML tag and a zero length string sends an empty tag.

Does setting the "Allow zero length string" option in the table definition help? It may force an empty string to be interpreted as NULL.

Are you talking about needing to do it in Datasheet view? If you needed to do it in an update query, you can do it like this:
UPDATE test SET test.test = Null;

press ctrl-0 and a null is inserted.

Deleting all the characters will work, but Access is a bit fickle. Hitting backspace or delete will not work unless there are characters in the field. I find it is best to enter a few characters, select all, and hit delete, change focus and change the record. After all the above, if you run a query looking for "is null" the record will be found.

I'm actually looking for a way for a layperson to do the entry directly in a table. In MSSQL you can simply press ctrl-0 and a null is inserted. Deleting all the characters doesn't appear to work. Instead of a null, you are left with an empty string. They are not treated the same by Access for export purposes.
I think what I'm going to wind up doing is creating an xslt file to use during export that eliminates empty tags. That way the user can't really tell the difference.
It sure would be nice, though, to be able to key in a null.

Ok, I don't think this is an easily solvable problem and my original question was a little off target. The problem isn't so much with nulls, although they are involved, as with the manner in which the table was originally created. If you use an xsd file to create your tables you plan on exporting, something happens under the hood in Access that causes those fields to be treated a little differently than fields created with the editors.
The only solution I found was to create a new field in the table, rename the old field, copy the data from the old field to the new field and delete the old field.
After doing that, then blank fields that had data in them at one point are no longer included in the XML output. It's probably not the best way to do this, and I still don't know exactly why it's happening, but at least I can get past the issue.

Just delete all characters in the column and access will insert a null value for you if the coumn allows it.

Related

Opening table shows "Enter parameter value"

I've done something to my Access database, and now when I double-click a table (all Access Objects | Tables) it puts up the "Enter Parameter Value" dialog. The parameter that it is asking for is of the form TableName.ColumnName, and ColumnName is indeed a column in TableName, but TableName is NOT the table I am opening. As it is a table I am opening, not a query or report etc., I have no idea what is causing this or what to do about it. If I just hot OK it seems to then open the table fine, but I'd like to fix it if I can.
Open the table in Design View and then open its property sheet. Make sure you examine the table's property sheet (it should say "Selection type: Table Properties" just below the "Property Sheet" heading).
Look for [TableName].[ColumnName] in one of those properties.
I was thinking of the Filter and Order By properties; you confirmed it was in the Order By.
That can happen when you apply a sort option from the ribbon and then save that sort with the table's design.
I just ran into this same problem. The parameter mine was asking for what not even one of my field names. I finally figured out that I must have hit the space key in an empty field when I was adding some new fields to the table. I deleted about 10 empty fields to make sure I got all the mistakes and it cleared up my problem. I hope this helps!

Form fields show '#DELETED' after running 'acCmdSaveRecord'

I've been having an issue today where one of my forms is filling all fields with "#DELETED" after I save the record. This wasn't happening three hours ago, and it seems to have started without me changing anything on the form itself. The record is still being saved, and there are no "#DELETED" entries in the table at any point. I am using the following code to open the form:
DoCmd.OpenForm "frmPoster", , , , acFormAdd
This is the code that saves it:
Call DoCmd.RunCommand(acCmdSaveRecord)
I am using Access2010 with SQL Server and VB. As I said, the really confusing part is that seemingly nothing has changed about this form that would be causing this. It worked, and now it doesn't. Any ideas?
Also, if you want any more information regarding the issue, I will be happy to provide.
I've used SQL with Access a lot and had some similar problems, I'd advise unless you have already to make sure you have a timestamp field in the SQL data, and also do a me.requery in VBA after the update so it re-selects the record.
I ran into the same problem yesterday - as soon as I try to save the record, all fields turn to #Deleted. Tried to resolve for hours - no luck.
I use Access 10 / 2016 and MySQL ODBC connector 5.3.
I narrowed it down to one specific field with a 13 digit number.
The datatype for the field was varchar. When I enter any value that does not match the required format (as checked by VBA), and then delete or edit it and move to the next field, the form refuses to create the UserID upon save and gives #Deleted.
If I skip this field during data entry, then the form creates the UserID (Primary Key) and saves. Also, if I enter a value that matches the field criteria first time round, the form generates the Primary key and saves.
As suggested somewhere I changed the datatype to numeric 14,0 for this field.
This did not help.
I tried to requery the form after saving as suggested but since the record is deleted, it simply displays blank fields.
So here is my hack:
1. On the "On Enter" event of the first field in the form, run code to set temporary values in each of the required fields, for example:
First I created an unbound hidden field with default value of "No". Then:
If Me.NewRecord=True and Me.FormPreppedYN="No" then
Me.txtFirstName="Hello"
Me.txtLastName="There"
Me.IDNr=123
Me.Ref="ABC"
Me.Dirty=False
Me.txtFirstName=""
Me.txtLastName=""
Me.IDNr=Null
Me.Ref=""
Me.txtFirstName.SetFocus
Me.FormPreppedYN="Yes"
End If
This forces the form to create a Primary key. This happens very quick and the user doesn't notice it. They just enter the data.
This worked reliably every time. I still don't know what causes the error, but this fixes it.

"Enter Paramater Value" Box for deleted field

This is my first database I am building, and am no Access expert, but I do think that I understand the basics.
I have deleted an old field from the back end of a split database, and edited the record sources of the forms that use the table as the record source. I deleted several fields, but one (a number field) is giving me trouble. Whether I open the underlying table or the forms that use the table as a recordsource, an "Enter Paramater Value" Dialogue box appears asking for the value on the form. I have looked at an older version of the database, and the field is not a primary key. I am quite stumped on this one. I have confirmed that the field is deleted from the recordsources and the table, so I'm not sure why it is still behaving like this.
Thanks.
Check Order by and Filter properties of the forms and queries which show such error.

Access data type conversion

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.

Access Validation Rule Violations on Append Query

I'm recieving the following error on trying to run an append query in access.
Microsoft Office Access set .... and it didnt't add... 779280 records(s) due to validation rule violations.
If I choose to run the query anyways, nothing actually happens.
To give some context, I'm simply trying to copy a populated field, consisting of values similar to "16-2009-02, 34-2010-02, et cetera" to another currently unpopulated field.
The fields themselves have no set validation rules, and both have the standard text field options.
I'm hoping to be able to simply remove those hyphens, and fix the issue. But I guess that's what I'm not sure about, are those hyphens actually a problem?
Running SP3 w/ Access 2003.
Thanks in advance!
Does the destination field have Allow Zero Length set to false or Required set to true? If it does, it is possible that some of the data from the source column is null or is set to an empty string. In addition, you should verify that the field sizes on the new column is equal to larger than the source column.
EDIT On appending from one table to another, you must ensure that you populate the columns that makeup the primary key of the destination table. Thus, from your screenshot, you need to include the loggerid and datetime columns from the "Log ID" table. Now, if there are collisions, Access should tell you how many rows generated collisions and let you append the ones that did not collide with the uniqueness restriction on loggerid and datetime
Make sure the target column is not indexed or, if it is, that duplicates are allowed. Access often makes indexing decisions on your behalf and sometimes they are not correct.