Runtime Error 2448 - Can't assign a value

D

Don

Please, I hope someone can help me; I'm obviously an idiot.

I have a form with a control that is an auto number. I'm trying-by clicking
a button-to open another form and insert the value of the control that is an
auto number, into a control on the other form. When I do this, I get the
Runtime Error 2448.

The control on the other form is formatted as a number (long integer) and
the control is in the form's header, which is invisible.

I've done this before on other databases that I've written. What am I
missing? I've included my code below:

Private Sub lstQUOTE_Click()
DoCmd.OpenForm "frmQUOTE_HEADER_A"
[Forms]![frmQUOTE_HEADER_A].SetFocus
[Forms]![frmQUOTE_HEADER_A]![QUOTE_ID] = Me.lstQUOTE
End Sub

By the way, I'm using Access 2007.
 
G

Graham Mandeno

Hi Don

If I understand you correctly, [frmQUOTE_HEADER_A]![QUOTE_ID] is bound to an
AutoNumber field.

You cannot assign a value to an AutoNumber field - the values get
automatically assigned as new records are created.

If you want to open [frmQUOTE_HEADER_A] to show an existing record, the one
with [QUOTE_ID] matching lstQuote, then use the WhereCondition of the
OpenForm method:

DoCmd.OpenForm "frmQUOTE_HEADER_A", _
WhereCondition:="[QUOTE_ID]=" & Me.lstQuote

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Don said:
Please, I hope someone can help me; I'm obviously an idiot.

I have a form with a control that is an auto number. I'm trying-by
clicking
a button-to open another form and insert the value of the control that is
an
auto number, into a control on the other form. When I do this, I get the
Runtime Error 2448.

The control on the other form is formatted as a number (long integer) and
the control is in the form's header, which is invisible.

I've done this before on other databases that I've written. What am I
missing? I've included my code below:

Private Sub lstQUOTE_Click()
DoCmd.OpenForm "frmQUOTE_HEADER_A"
[Forms]![frmQUOTE_HEADER_A].SetFocus
[Forms]![frmQUOTE_HEADER_A]!
 
D

Don Rountree

No, [frmQUOTE_HEADER_A]![QUOTE_ID] is not an AutoNumber, it is simply
formatted as a number. The "Me.lstQUOTE" in my code is the AutoNumber;
however, I will try your fix when I get to work in the morning. Thanks.

Graham Mandeno said:
Hi Don

If I understand you correctly, [frmQUOTE_HEADER_A]![QUOTE_ID] is bound to an
AutoNumber field.

You cannot assign a value to an AutoNumber field - the values get
automatically assigned as new records are created.

If you want to open [frmQUOTE_HEADER_A] to show an existing record, the one
with [QUOTE_ID] matching lstQuote, then use the WhereCondition of the
OpenForm method:

DoCmd.OpenForm "frmQUOTE_HEADER_A", _
WhereCondition:="[QUOTE_ID]=" & Me.lstQuote

--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

Don said:
Please, I hope someone can help me; I'm obviously an idiot.

I have a form with a control that is an auto number. I'm trying-by
clicking
a button-to open another form and insert the value of the control that is
an
auto number, into a control on the other form. When I do this, I get the
Runtime Error 2448.

The control on the other form is formatted as a number (long integer) and
the control is in the form's header, which is invisible.

I've done this before on other databases that I've written. What am I
missing? I've included my code below:

Private Sub lstQUOTE_Click()
DoCmd.OpenForm "frmQUOTE_HEADER_A"
[Forms]![frmQUOTE_HEADER_A].SetFocus
[Forms]![frmQUOTE_HEADER_A]![QUOTE_ID] = Me.lstQUOTE
End Sub

By the way, I'm using Access 2007.
 
M

miciomao

Hi Don
try

Private Sub lstQUOTE_Click()
DoCmd.OpenForm "frmQUOTE_HEADER_A"
[Forms]![frmQUOTE_HEADER_A]![QUOTE_ID].SetFocus
[Forms]![frmQUOTE_HEADER_A]![QUOTE_ID].Text = Me.lstQUOTE
End Sub

Ciao
Alex
 

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

Similar Threads


Top