Rnd column in attribute table, strange behaviour

3935
7
Jump to solution
03-30-2015 03:13 AM
NeilAyres
MVP Alum

This whole thing started when I wanted to make a random number column and populate it in an attribute table.

I added a column to the table called "Rnd" (type double).

Rnd_FieldProperties.jpg

Then I opened the field calculator to populate this with a random number. But then I noticed that it was already populated with a number, all the same.

Even when I calculated the field to any number (in this case 2), a different random float would appear.

Rnd_CalcField.jpg

Even opening the table would generate another.

Strangely, after the calc above, I closed ArcMap, and opened the table in Access (this is in a personal geodb), the contents = 2.

Rnd_Random1.jpgRnd_Random2.jpg

Is this behavior, for a field called "Rnd" documented anywhere?

And, just in case I am totally loosing it, can someone confirm that this happens on another system.

My version 10.2.2.

Thanks.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DarrenWiens2
MVP Honored Contributor

I do see the same behaviour with Rnd as field name (v10.2.2). It appears to be a problem (bug or feature?) with using an unhandled VBScript (or VBA possibly) function as a field name. I see similar behaviour using Now as a string field name: the Now() function returns a string of the current date/time. The Now() function appears to be called every time field calculator is opened.

Some field names are reserved, like "Date", which indicates some VB functions have been handled, but not all.

View solution in original post

7 Replies
JamesCrandall
MVP Frequent Contributor

Perhaps a 64-bit issue?

I'm not 100% sure on this, but maybe research the future of the Personal GDB.

0 Kudos
BlakeTerhune
MVP Regular Contributor

I'm on 10.2.2 and just tested this with a new Personal GDB and did not have the same issue. The Rnd field was not automatically populated.

0 Kudos
JamesCrandall
MVP Frequent Contributor

In your OP you stated that this problem occurred with the PGDB:

I closed ArcMap, and opened the table in Access (this is in a personal geodb)

I was commenting that since Access is a 32-bit application, perhaps the problems are associated with ArcGIS accessing that application.  I don't have a definitive solution or even if that is your problem, it was just a comment to perhaps check into.

I would definitely be concerned with implementing PGDB's though and consider the future of that technology.

0 Kudos
DarrenWiens2
MVP Honored Contributor

I do see the same behaviour with Rnd as field name (v10.2.2). It appears to be a problem (bug or feature?) with using an unhandled VBScript (or VBA possibly) function as a field name. I see similar behaviour using Now as a string field name: the Now() function returns a string of the current date/time. The Now() function appears to be called every time field calculator is opened.

Some field names are reserved, like "Date", which indicates some VB functions have been handled, but not all.

NeilAyres
MVP Alum

Darren, thanks for confirming this and for providing a possible explanation.

Will try a "Now" attribute as well.

0 Kudos
NeilAyres
MVP Alum

Darren is absolutely spot on.

VbFunctionsAsFieldNames.jpg

A field named Now (as a date) has the same result. Automatically populated...

The only question is...

Is this an undocumented feature or an undocumented bug.

0 Kudos
JamesCrandall
MVP Frequent Contributor

I wouldn't necessarily describe it as a bug or a problem.  It's pretty common to not use reserved words as a practice and a good habit to get into.  In rare cases where I needed to name a field close to a reserved word then I'd just add an underscore "_" in front of the name. 

0 Kudos