Error: 2448 You can't assign a vaule to this object

R

Ripper

This is the code that I get the error on. The ^^^^^^^ show where the errors are and why I am confused

'Highest form numbe
Const lngcUpperBound = 1

'Lowest form numbe
Const lngcLowerBound =

Dim lngFormNumber As Lon
Dim strRandomMonth As Strin

'Generate a random number in the specified range. See 'Rnd Function' in the help file for details
Randomize Time
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound

strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID = " & lngFormNumber

Me![RandomMonth] = strRandomMonth <-- Me![RandomMonth] is an unbound text and it work
^^^^^^^^^^^^^^^^^^^^^^^^^^
Me![Month] = strRandomMonth <- Me![Month] is a field in the table tblData. This is where the error occurrs
^^^^^^^^^^^^^^^^^^^^^
Would appreciate any tips you might have
RI
 
D

Douglas J. Steele

Month is a reserved word, and shouldn't be used for anything you build. Try
changing the name in the table. As well, there are often problems when the
name of the text box and the name of the field to which it's bound are the
same. Assign a different name to the text box.

--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ripper said:
This is the code that I get the error on. The ^^^^^^^ show where the
errors are and why I am confused.
'Highest form number
Const lngcUpperBound = 12

'Lowest form number
Const lngcLowerBound = 1

Dim lngFormNumber As Long
Dim strRandomMonth As String

'Generate a random number in the specified range. See 'Rnd Function' in the help file for details.
Randomize Timer
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound)

strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID = " & lngFormNumber)

Me![RandomMonth] = strRandomMonth <-- Me![RandomMonth] is an unbound text and it works
^^^^^^^^^^^^^^^^^^^^^^^^^^
Me![Month] = strRandomMonth <- Me![Month] is a field in the table
tblData. This is where the error occurrs.
 
R

Ripper

Thanks for staying with me Douglas

'Generate a random number in the specified range. See 'Rnd Function' in the help file for details
Randomize Time
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound

strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID = " & lngFormNumber
Me![RandomMonth] = strRandomMont

Me![Stored] = strRandomMonth <----- still get the 2448 error on this line.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I changed the name of the field to StoredMonth in the table and the name of the box in the form is Stored and its control source is tblData.StoredMonth

Why does it go into the unbound textbox and not the controlled field

This is beginning to drive me NUTS

RI
 
B

Brendan Reynolds

Is the form bound directly to the table, or to a query or SQL statement
based on the table? If the latter, is the field 'StoredMonth' included in
the query or SQL statement?

Is the control source of the text box 'Stored' simply the name of the field,
or is it an expression that refers to the name of the field, such as
'=[StoredMonth]'?

--
Brendan Reynolds (MVP)

Ripper said:
Thanks for staying with me Douglas.

'Generate a random number in the specified range. See 'Rnd Function' in the help file for details.
Randomize Timer
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound)

strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID = " & lngFormNumber)
Me![RandomMonth] = strRandomMonth

Me![Stored] = strRandomMonth <----- still get the 2448 error on this line.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I changed the name of the field to StoredMonth in the table and the name
of the box in the form is Stored and its control source is
tblData.StoredMonth.
 
B

Brendan Reynolds

I can't see any reason why this would not work, but here are a couple more
questions that might perhaps point toward an answer - what's the data type
of the field 'StoredMonth', and what event procedure contains the code?
--
Brendan Reynolds (MVP)

Ripper said:
The form is bound to the table, tblData.

The control source for the textbox 'stored' is StoredMonth on the same
table that the form is based on, tblData.
RIP


----- Brendan Reynolds wrote: -----

Is the form bound directly to the table, or to a query or SQL statement
based on the table? If the latter, is the field 'StoredMonth' included in
the query or SQL statement?

Is the control source of the text box 'Stored' simply the name of the field,
or is it an expression that refers to the name of the field, such as
'=[StoredMonth]'?

--
Brendan Reynolds (MVP)

Ripper said:
Thanks for staying with me Douglas.
Function' in
the help file for details.
Randomize Timer
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd
+
lngcLowerBound)
strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID =
" &
lngFormNumber)
Me![RandomMonth] = strRandomMonth
Me![Stored] = strRandomMonth <----- still get the 2448 error
on this
line.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the name
of the box in the form is Stored and its control source is
tblData.StoredMonth.
 
D

Douglas J. Steele

The error message for error 2448 is:

:You can't assign a value to this object.@* The object may be a control on a
read-only form.
* The object may be on a form that is open in Design view.
* The value may be too large for this field.@@1@209424@1"

(ignore the funny characters: I got the messages by typing
?AccessError(2448) in the Debug window, and those characters are place
holders for when the error is raised in actual use)

Is your form bound to a query? Is that query updatable? Otherwise, as
Brendan asked, what's the data type of StoredMonth in the table?


--
Doug Steele, Microsoft Access MVP

(No private e-mails, please)


Ripper said:
Thanks for staying with me Douglas.

'Generate a random number in the specified range. See 'Rnd Function' in the help file for details.
Randomize Timer
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rnd + lngcLowerBound)

strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID = " & lngFormNumber)
Me![RandomMonth] = strRandomMonth

Me![Stored] = strRandomMonth <----- still get the 2448 error on this line.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I changed the name of the field to StoredMonth in the table and the name
of the box in the form is Stored and its control source is
tblData.StoredMonth.
 
R

Ripper

StoredMonth - text field 30 char lon
No special stuff in it. No default text or anything. No index zero length allowed etc

The event proc is OnOpe

You can see why this is driving me crazy then

RI
----- Brendan Reynolds wrote: ----

I can't see any reason why this would not work, but here are a couple mor
questions that might perhaps point toward an answer - what's the data typ
of the field 'StoredMonth', and what event procedure contains the code
-
Brendan Reynolds (MVP

Ripper said:
The form is bound to the table, tblData
The control source for the textbox 'stored' is StoredMonth on the sam table that the form is based on, tblData
RI
Is the form bound directly to the table, or to a query or SQ
statemen
based on the table? If the latter, is the field 'StoredMonth included i
the query or SQL statement
Is the control source of the text box 'Stored' simply the name of th
field
or is it an expression that refers to the name of the field, such a
'=[StoredMonth]'
- Brendan Reynolds (MVP
Thanks for staying with me Douglas
Function' i
the help file for details
Randomize Time
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) * Rn
lngcLowerBound
strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID
" &> lngFormNumber
Me![RandomMonth] = strRandomMont
Me![Stored] = strRandomMonth <----- still get the 2448 erro
on thi
line
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the nam
of the box in the form is Stored and its control source i
tblData.StoredMonth
 
R

Ripper

The form is bound to a table, tblData

I tried deleting the field and re-inserting it on the form, but that did not work. Sometimes I change data types and forget to put it back on the form with the new type

Time to pull out the sword and fall on it I guess. =

RIP
 
B

Brendan Reynolds

Try the Load event instead of the Open event.

--
Brendan Reynolds (MVP)

Ripper said:
StoredMonth - text field 30 char long
No special stuff in it. No default text or anything. No index zero length allowed etc.

The event proc is OnOpen

You can see why this is driving me crazy then.

RIP
----- Brendan Reynolds wrote: -----

I can't see any reason why this would not work, but here are a couple more
questions that might perhaps point toward an answer - what's the data type
of the field 'StoredMonth', and what event procedure contains the code?
same
table that the form is based on, tblData.
statement
based on the table? If the latter, is the field 'StoredMonth' included in
the query or SQL statement?
name of the
field,
or is it an expression that refers to the name of the field, such as
'=[StoredMonth]'?
-- Brendan Reynolds (MVP)
"Ripper" <[email protected]> wrote in
message
Thanks for staying with me Douglas.
'Generate a random number in the specified range. See 'Rnd
Function' in
the help file for details.
Randomize Timer
lngFormNumber = Int((lngcUpperBound - lngcLowerBound + 1) *
Rnd
+
lngcLowerBound)
strRandomMonth = DLookup("[Month]", "tblMonthsofYear", "ID = " &> lngFormNumber)
Me![RandomMonth] = strRandomMonth
Me![Stored] = strRandomMonth <----- still get the 2448 error
on this
line.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I changed the name of the field to StoredMonth in the table and
the name
of the box in the form is Stored and its control source is
tblData.StoredMonth.
Why does it go into the unbound textbox and not the controlled field?
This is beginning to drive me NUTS!
RIP
[/QUOTE]
 

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