Keep Name for new form (1 Viewer)

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
Hi Everyone don't know if anyone can help with the following :-

Just entering new customer information and would like to copy this info across to order from which I open from the customer input form and get the error message "Error 2448" (You can not assign a value to this object) The code I put in is :-


Private Sub OpenOrderInputForm_Click()

DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenForm "Form Orders Input", acNormal, , , acAdd

Forms![Form Orders Input]![CustomerID] = Me![CustomerID] ' This the line having a problem with

End Sub

Thanks All
 

Minty

AWF VIP
Local time
Today, 17:58
Joined
Jul 26, 2013
Messages
10,355
What is the control source for CustomerID on the order form?
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
What is the control source for CustomerID on the order form?
Control is the Primary Key in customers table also an Autonumber
 

Minty

AWF VIP
Local time
Today, 17:58
Joined
Jul 26, 2013
Messages
10,355
I hope it isn't the Primary Key on the ORDERS form?
What is the control source for the CustomerID on the ORDERS form?
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
I hope it isn't the Primary Key on the ORDERS form?
What is the control source for the CustomerID on the ORDERS form?
No the primary key in the Orders table is OrderID and CustomerID is a Number
 

Minty

AWF VIP
Local time
Today, 17:58
Joined
Jul 26, 2013
Messages
10,355
I'll try again.

On the orders Form I assume you have control called CustomerID.
That control has a control source. What is it set to? Picture of a similar control below;
1655976694218.png
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
I'll try again.

On the orders Form I assume you have control called CustomerID.
That control has a control source. What is it set to? Picture of a similar control below;
View attachment 101379
Hi Minty

I have a drop down Combo Box on the order from but this is unbound and work perfectly well but my object is to enter the new customer details into Customer Details form and keep this information and display it on the Order Form without having to select from the Combo Box.

Hope you can understand my rambling.

Thank you
 

Minty

AWF VIP
Local time
Today, 17:58
Joined
Jul 26, 2013
Messages
10,355
I completely understand what you are trying to do.
Your problem is that whatever Forms![Form Orders Input]![CustomerID] control is, it won't accept you assigning a value to it.

In order to know why, we need to know what the ControlSource of Forms![Form Orders Input]![CustomerID] is set to.

So pretty please can you answer my question - What is the ControlSource of Forms![Form Orders Input]![CustomerID] as per the property setting the same as my picture. I don't know how else to ask you?
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
Hi Again Minty

Sorry to be a pain but one unfortunate thing is I have Covid first time and I do feel exhausted , can I come back to you later and in the meantimde I will try to answer all the questions you have put to me.

Thanks
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
I have checked all across both of the forms I am using ie.

Form Customer Details Input :
The form itself does not have a Control Source
only a Record Source which is the tblCustomers and all the fields on Form have a Control Source from the tblCustomers

Form Orders Input :
Again The Form itself does not have a Control Source only a Record Source which is again the tblCustomers and again all the fields on Form have a Control Source from the tblCustomers.

The SubForm on the Orders Input Form has only a Record Source which is a Query.

I have placed the cursor over the line of code that I’m having the problem with and it has had two statements showing one was
Me![CustomerID] “ is Null
and the other
Me![CustomerID] < The Expression you entered referrers to an object that is cl…

Can not get any more info.

Again thanks for taking the trouble to try and help
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:58
Joined
Sep 21, 2011
Messages
14,045
Why not just show a picture of the CustomerID Data Property tab as requested in post #6? :(
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:58
Joined
May 21, 2018
Messages
8,463
If I understand this correctly you are trying to set the value of the customerID which is an autonumber in tblCustomers. That will give the stated error. You cannot assign a value to an autonumber field.

By chance are you trying to move to a record? If so that is not the correct code.
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
I see what you are saying about Autonumber , the record I was / am trying to use is the record just entered via Customer Inp0ut form. Mind in saying all this perhaps its just as well to select from combobox rather than trying to write different code.

Thank for your help.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:58
Joined
May 21, 2018
Messages
8,463
You can open to that newly created record using the docmd.openform Where argument
 

LarryE

Active member
Local time
Today, 10:58
Joined
Aug 18, 2021
Messages
562
Also, if you are setting a controls value with code, make sure that controls Default Value is blank. If it is not, that will also cause an error.
 

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
All I can see in Default in Properties is Fetch Default and Option is set to Yes
 

LarryE

Active member
Local time
Today, 10:58
Joined
Aug 18, 2021
Messages
562
You are confusing the form properties with the individual control properties on the form.
  1. Open the form in design mode
  2. Find the textbox control named CustomerID and select it
  3. In the CustomerID properties window, look for the Default Value property
  4. Make sure it is blank
Further, it sounds like you are using ACCESS like a spreadsheet by passing values between forms. Do you have Primary Keys and Foreign Keys established so that relationships can exist between your tables? Have you established these relationships? Because if you have not, then you need to start over with your design and get that properly established first.

That said, if both forms are open and assuming:
  1. The customer input form has the correct customer record selected
  2. The Orders Input form has a new record selected AND is the active form
  3. Then you can pass the CustomerID FROM the customer input form TO the Order input form with:
Me.CustomerID = Forms![Form Orders Input]![CustomerID]
The 'Me' refers to the active order input form. You have it backwards in your original code.
And this is assuming the CustomerID textbox on the customer input form AND the CustomerID textbox on the order input form BOTH are named CustomerID.

Also, remove the DoCmd.RunCommand acCmdSaveRecord. It is useless.
 
Last edited:

A17BPG

New member
Local time
Today, 10:58
Joined
Mar 30, 2018
Messages
23
Thanks Everyone will try out all your suggestions hopefully in the next couple of days.

Thanks Again
 

Minty

AWF VIP
Local time
Today, 17:58
Joined
Jul 26, 2013
Messages
10,355
You missed the point of my question completely I'm afraid.
I'm not asking about the Forms record source, just the individual control which is the value you are trying to change.

So take a screenshot of the CustomerID control properties on the order form.
Preferably with its Control Source showing as per my screenshot.
 

Users who are viewing this thread

Top Bottom