Add Control get - (New) - displayed in the field

R

Richo

I deleted a control from a form and then added a new one by dragging it on
when clicking on the add existing fields button. I renamed it and then ran it
in form view, everything was the same except that now there is "(New)
displayed in the new field and when I click on the create button to add the
next Auto number I get error #:2135 This property is read only and can't be
set.

Hope you can understand this question and help me.

Thanks

Richo
 
D

Douglas J. Steele

You can't assign a value to an AutoNumber field: you must let Access assign
the value.
 
R

Richo

Hi Doug
Thanks for the tip however I am not sure how to accomplish that.
When the user clicks the create button I am trying to display the next
autonumber using the following code
recNumber![ID] = DMax("[ID]", "[meal]") + 1

Me.num_meal_number.Enabled = True
Me.num_meal_number.SetFocus
Me.num_meal_number.Text = recNumber![ID]

also why I am asking questions, I am just starting to use access 2007 after
a few years off (From 2003) and to be able to clear a field I get lots of
errors like can not set focus ect
How do you clear a field, the below was how I was trying to do it...
Me.num_meal_number.SetFocus
Me.num_meal_number.Text = " "
Me.num_meal_number.Enabled = False
Me.txt_meal_name.SetFocus
Me.txt_meal_name.Text = ""

Thanks
 
D

Douglas J. Steele

From your original post, it sounds as though you changed ID to an AutoNumber
field. You cannot use recNumber![ID] = DMax("[ID]", "[meal]") + 1 if ID is
an AutoNumber field. Either change the field type back to Long Integer, or
remove that line of code.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Richo said:
Hi Doug
Thanks for the tip however I am not sure how to accomplish that.
When the user clicks the create button I am trying to display the next
autonumber using the following code
recNumber![ID] = DMax("[ID]", "[meal]") + 1

Me.num_meal_number.Enabled = True
Me.num_meal_number.SetFocus
Me.num_meal_number.Text = recNumber![ID]

also why I am asking questions, I am just starting to use access 2007
after
a few years off (From 2003) and to be able to clear a field I get lots of
errors like can not set focus ect
How do you clear a field, the below was how I was trying to do it...
Me.num_meal_number.SetFocus
Me.num_meal_number.Text = " "
Me.num_meal_number.Enabled = False
Me.txt_meal_name.SetFocus
Me.txt_meal_name.Text = ""

Thanks
--
Regards

Richo


Douglas J. Steele said:
You can't assign a value to an AutoNumber field: you must let Access
assign
the value.
 
R

Richo

Thanks for your help, will make the changes
--
Regards

Richo


Douglas J. Steele said:
From your original post, it sounds as though you changed ID to an AutoNumber
field. You cannot use recNumber![ID] = DMax("[ID]", "[meal]") + 1 if ID is
an AutoNumber field. Either change the field type back to Long Integer, or
remove that line of code.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Richo said:
Hi Doug
Thanks for the tip however I am not sure how to accomplish that.
When the user clicks the create button I am trying to display the next
autonumber using the following code
recNumber![ID] = DMax("[ID]", "[meal]") + 1

Me.num_meal_number.Enabled = True
Me.num_meal_number.SetFocus
Me.num_meal_number.Text = recNumber![ID]

also why I am asking questions, I am just starting to use access 2007
after
a few years off (From 2003) and to be able to clear a field I get lots of
errors like can not set focus ect
How do you clear a field, the below was how I was trying to do it...
Me.num_meal_number.SetFocus
Me.num_meal_number.Text = " "
Me.num_meal_number.Enabled = False
Me.txt_meal_name.SetFocus
Me.txt_meal_name.Text = ""

Thanks
--
Regards

Richo


Douglas J. Steele said:
You can't assign a value to an AutoNumber field: you must let Access
assign
the value.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I deleted a control from a form and then added a new one by dragging it
on
when clicking on the add existing fields button. I renamed it and then
ran
it
in form view, everything was the same except that now there is "(New)
displayed in the new field and when I click on the create button to add
the
next Auto number I get error #:2135 This property is read only and
can't
be
set.

Hope you can understand this question and help me.

Thanks

Richo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top