Error trying to add new record on form with subform

G

Guest

I have a Corporate Data Form that shows all the details of our corporate
clients. This is accessed from the built-in switchboard, in either Edit Mode
or in Add mode and has been working fine.
Recently I created and added to this a subform to contain details of the
Contacts at each of the clients (there can be several) which are held in a
separate table. These are linked to the company record by the common field
CorpName on a one to many relationship.
Everything looked good and was working well, until today we tried to use Add
New Corp Record and as soon as we selected this from the switchboard and
opened the form, we got VB error "Run-time error 3021 - no current record".
The debugger is highlighting the centre line of this piece of code:
Private Sub Form_Current()
Me.txtCurrent = Me.CurrentRecord
Me.RecordsetClone.MoveLast (THIS LINE HIGHLIGHTED)
Me.txtTotal = Me.RecordsetClone.RecordCount
End Sub

My first guess is that the system is trying to find the subform records that
exist for the parent record, but of course as this is a new blank record,
there are none. Maybe I'm completely off the track here but whatever, I am
lost for fixing it and it's a big problem as we now cannot add any new
corporate client records. (Good excuse for our salespeople to take a break,
but not really in the best interests of the company's future).

Advice, please????
Many thanks
CW
 
K

kingston via AccessMonster.com

Is the focus in the subform (with no records, hence no current record) when
you attempt to do this? I'm guessing that Add New Corp Record is a button on
the main form. You can force the focus back to the main form by going to a
control on the main form first:

DoCmd.GoToControl Me.ControlName
 

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