Computer_Support_Norwich
asked on
Issue with openargs, run time error 2448. You can't assign a value to this object.
I'm probably doing this the wrong way, but here goes.
I have a form 'frmCustomer'.
On the form is a button to open 'frmContactPopup' in order to create a new contact for a given customer.
So, the code on the button is:
DoCmd.OpenForm "frmContactPopup", acNormal, , , acFormAdd, , OpenArgs:=Me.customerid.Va lue
And the code on the frmContactPopup is:
If Me.NewRecord Then
Me.customerid.Value = Me.OpenArgs
End If
But the frmContactPopup never gets populated with the customerid.
The error is:
Run-time error 2448 - You can't assign a value to this object.
I think this may be the wrong approach...? How do I load a new form, to create a new record, based upon data in this 'parent' form.
For display related reasons I would rather not use a subform which is one solution.
I have a form 'frmCustomer'.
On the form is a button to open 'frmContactPopup' in order to create a new contact for a given customer.
So, the code on the button is:
DoCmd.OpenForm "frmContactPopup", acNormal, , , acFormAdd, , OpenArgs:=Me.customerid.Va
And the code on the frmContactPopup is:
If Me.NewRecord Then
Me.customerid.Value = Me.OpenArgs
End If
But the frmContactPopup never gets populated with the customerid.
The error is:
Run-time error 2448 - You can't assign a value to this object.
I think this may be the wrong approach...? How do I load a new form, to create a new record, based upon data in this 'parent' form.
For display related reasons I would rather not use a subform which is one solution.
You can set default value for field customerid on form frmContactPopup to
Forms!frmCustomer.customer id
and new records will have this value
Use builder for proper syntax.
Forms!frmCustomer.customer
and new records will have this value
Use builder for proper syntax.
openargs should be a bucket of variables,
you might need to assign it to a variable in openargs
OpenArgs.CustomerID:=Me.cu stomerid.V alue
http://msdn.microsoft.com/en-us/library/office/aa160845(v=office.10).aspx
you might need to assign it to a variable in openargs
OpenArgs.CustomerID:=Me.cu
http://msdn.microsoft.com/en-us/library/office/aa160845(v=office.10).aspx
ASKER
Thanks all. I'll look at these right now.
ASKER
The record source for frmContactPopup WAS coming from the query builder, rather than a proper query or table. I have changed this so the data comes direct from a proper query. I have no idea if this will help, but it seems like the right thing to do.
peter57r
========
customerid is from an autonumber field.
als315
======
That's a fair point, but I use this frmContactPopup when looking at existing comntacts, not just for adding new ones, so not sure if that would work?
rg20
====
I get a compile error (Expected: end of statement when changing my button code to:
DoCmd.OpenForm "frmContactPopup", acNormal, , , acFormAdd, , OpenArgs.CustomerID:=Me.cu stomerid.V alue
I have attached a copy of the DB for reference.
database.zip
peter57r
========
customerid is from an autonumber field.
als315
======
That's a fair point, but I use this frmContactPopup when looking at existing comntacts, not just for adding new ones, so not sure if that would work?
rg20
====
I get a compile error (Expected: end of statement when changing my button code to:
DoCmd.OpenForm "frmContactPopup", acNormal, , , acFormAdd, , OpenArgs.CustomerID:=Me.cu
I have attached a copy of the DB for reference.
database.zip
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
"customerid is from an autonumber field."
Then you cannot assign a value to it.
I suspect al315 may have the answer above.
Then you cannot assign a value to it.
I suspect al315 may have the answer above.
ASKER
Ahhhhhhh. Thanks for the feedback will try this out later today.
ASKER
als315... worked a treat, thanks!
I really appreciate everybodys time on this. I wish it were as obvious to me as it is to you...
I really appreciate everybodys time on this. I wish it were as obvious to me as it is to you...
ASKER
Thanks to everyone for their input. I know it was a 'quick one' for you, but saved me a lot of hassle.
What is the datatype of the customerid field that is displayed in frmContactPopup.