Form REFNO / Autonumber problem

chris-uk-lad

Registered User.
Local time
Today, 03:53
Joined
Jul 8, 2008
Messages
271
Hi,

My linked table has a field called REFNO which is a reference number for each record (autonumber).

When i use a form to add a new record, it shows (autonumber) in the textbox and the following error:

"you can't assign a value to this object.

*the object maybe a control on the read only form
*the object maybe on a form that is open in design view
*the value maybe too large for this field. "

I before used the following code but have since removed, neither time has it worked.

Code:
varID = DMax("[REFNO]", "Sheet1") + 1
[REFNO].Value = varID
 
Your code would update a "number" row-column, however, an Autonumber cannot be modified.
 
As llkhoutx has said, an AutoNumber cannot be modified or assigned by code, it is automatically generated by Access when a new record is created. If you go into Design View for your table and change the field's Datatype to Number/Integer your code should work.
 
I appreciate the comments though i would like to know any opinions of the error generated when left as an autonumber and not using the code
 
The error is correct. It indicating that uyou're trying to assign (set) an autonumber column.
 
I appreciate the comments though i would like to know any opinions of the error generated when left as an autonumber and not using the code
If you're saying that without using the code, you're still receiving the error, my guess would be that you still have code somewhere, in code or trying to assign a default value either at form level or table level, that you've forgotten to remove.
 
So if i was to cut this down to a simple 2 column table (name and autonumber) and create a form to add a second name, it would still generate an error? >_<
 

Users who are viewing this thread

Back
Top Bottom