How to add new record in sub form (1 Viewer)

neilhoop

Registered User.
Local time
Today, 18:12
Joined
Jun 10, 2009
Messages
45
Hi,

I have a form called Certificates with a subform on it called subClient.

The subform is located on a tab control on the first tab.

I have added a button below the subform to add a new record to it I'm using:

Dim stDocName As String
stDocName = "Forms![certificates]![subClient]"
DoCmd.GoToRecord acDataForm, stDocName, acNewRec

I just get an error saying The object 'Forms![certificates]![subClient]' isn't open

Can anybody tell me why?

----------
Neil
 
Last edited:

neilhoop

Registered User.
Local time
Today, 18:12
Joined
Jun 10, 2009
Messages
45
I didn't find the answer there so I changed tact.

I've decided to add some separate buttons to do all the things that I wanted to do with one button.

I've now got a strange error message when I try to enter data in the new record on the subform.

As soon as I start to type anything in the first field a message box pops up and says:

You can't assign a value to this object.

The object may be a control on a read only form.
The object may be on a from that is open in Design View.
The value may be too large for this field.

When OK is pushed it lets me carry on entering the data and will let me save it.

It seems a bit strange as I don't recall making the form read only, I don't even know how, and if it is read only why does it allow me to carry on entering data and save it.

It's not open in design view.

The value can't be too large for the field as at this point it hasn't actually been confirmed in the field.

Any ideas anyone?


----------
Neil
 

ajetrumpet

Banned
Local time
Today, 12:12
Joined
Jun 22, 2007
Messages
5,638
the only idea I have is that some other code, OR the setup of your forms are causing the error. A major issue with Access is that error messages, most of the time, are misleading. As in, they message that they display really doesn't explain to you what is going on and causing the actual problem. Care to upload your application? I'm sure you could get some eyes on it, and maybe get your problem fixed too...
 

ansentry

Access amateur
Local time
Tomorrow, 03:12
Joined
Jun 1, 2003
Messages
995
I don't know if this will work on a tab form, however when you have a command button on the main form and you want to go to a new record in the subform , you must first set the focus to the subform.

Hope this is some help.

Below is code from one of my db's.

Code:
Private Sub cmdNewRecordSubform_Click()
If IsNull(Me.MainID) = True Then
MsgBox "Your cannot add a record to the SubForm before you add a record in the Main Form", vbCritical, "Data Error"
Me.txtMainName.SetFocus

Else

Me.sfrmVehicles.SetFocus
DoCmd.GoToRecord , , acNewRec
DoCmd.GoToControl "txtVehicleMake"

End If
 

Users who are viewing this thread

Top Bottom