Error 2105 DoCmd.GoToRecord , , acNewRec (1 Viewer)

shenty

Registered User.
Local time
Today, 21:46
Joined
Jun 8, 2007
Messages
119
I have a strange problem. I am trying to add a new record to a subform but i keep getting the "Error 2105 - You can't go to the specified record".

I have to main forms (frmFeedOrder and frmMineralOrder), each form has a subform & a products listbox. When a product is selected in the list box (double click) it should add a new record to the subform and place the order details into it.

Strange thing is it works fine on the frmFeedOrder which i setup first but not the frmMineralOrder. The latter form i copy & pasted and changed the necessary fields.

Could anyone explain why i might be getting this error?

Sample db attached. (Use test farm as the active farm, then load Mineral Order from menu, select a product from listbox. Then try to select another product but it will not add the new record using the docmd.gotorecord , , acnewrec command).

Thanks in advance.
 

Attachments

  • Feed & Minerals Error 2105.zip
    62.5 KB · Views: 291

shenty

Registered User.
Local time
Today, 21:46
Joined
Jun 8, 2007
Messages
119
hmmm i found the problem that was causing it but i don't understand why really !

the name of some of the fields in the subform i must have forgot to change after pasting the tbl, qry and frms to the mineral 'version'.

i understand the problem but why would the error happen the line before the problem ?
 

Premy

Registered User.
Local time
Today, 13:46
Joined
Apr 10, 2007
Messages
196
Try to requery the subform

HTH
 

missinglinq

AWF VIP
Local time
Today, 16:46
Joined
Jun 20, 2003
Messages
6,423
i understand the problem but why would the error happen the line before the problem ?
What exactly do you mean by this? If you mean that the code errors out and instead of highlighting the line of code that was bad, highlights the line of code before the line causing the error, this is pretty normal for Access VBA. Never found anyone who could explain why, but I always consider the line before the highlighted line when debugging.

At any rate, glad you got it working.
 

shenty

Registered User.
Local time
Today, 21:46
Joined
Jun 8, 2007
Messages
119
What exactly do you mean by this?

What i meant was, when the form & subform are first loaded (or reloaded after) it adds the new record and fills in the boxes without failing. What it is doing is not adding a new record next time the listbox is double clicked.

The add new record command is generating the error 2105.!! I thought this odd as it doesn't error first time.

I noticed that the name for the 1st, 2nd, 5th & 6th text boxes of the subform had not been changed after i copied and pasted the subform from being a feed subform to a mineral subform (although i thought i had done). Althought the data control sources were set to the correct field from the query, the names were not. In my VBA code i have:-

Forms!frmMineralOrder!frmMineralOrderExtendedSubform!FarmMineralOrderID = Forms!frmMineralOrder!FarmMineralOrderID
but there was no text box of that name (it was still set as FarmOrderID.

I guess i would have expected the error to come from that line itself, basically telling me that it can't set a field on the subform to a value from the main form because that field doesn't exist.

Anyway mate thanks for spending the time to look at my problem. Let it be a lesson to all that whilst you think you may have done something maybe you didn't. Retrace your steps that you thought you did and double check them.

I still think the error was a bit misleading though ;)
 

Users who are viewing this thread

Top Bottom