trouble adding a new record on a subform

Mike-palmer

Registered User.
Local time
Today, 19:50
Joined
Mar 27, 2003
Messages
37
I’m having problems adding a new record on a subform. I used the “command button wizard” to add a new record on the form that’s used as a subform..

When the form is opened by itself the add record works fine.

But when I try and add a record when the form is a subform I get an error as soon as I type in any field: “You can’t assign a value to this object”. If I click on “OK” I can then continue typing on the form and everything is OK. Why am I getting this error each time?

Any help would be most appreciated.
 
Can you write the code which is in "on_click" event of buttom?
 
Yes, I have written most of the code that is already in the spreadsheet so I can compfortably add code to the present button....
 
Sorry....

Private Sub NewRecord_Click()
On Error GoTo Err_NewRecord_Click


DoCmd.GoToRecord , , acNewRec

Exit_NewRecord_Click:
Exit Sub

Err_NewRecord_Click:
MsgBox Err.Description
Resume Exit_NewRecord_Click

End Sub

This is the code the add wizard button created.
 
Where is your button? In Main form or subform?

Regards
 
The button is on the subform... I tried putting it on the main form and that didn't help... same problem.
 
I have tried and it works.

After DoCmd.GoToRecord , , acNewRec

try also to set focus to one of of your text:
text1.setfocus

Example:
DoCmd.GoToRecord , , acNewRec
text1.setfocus
 
I tried adding setfocus but it didn't help.

The error message says the object may be a control on a read only form or on a form that's open in design view or the value may be too large. I know it's not 2 or 3 and I don't see how the form would be read only, but it's a possibility. What's puzzling is that when I ignore the message I can enter the data in the new record. I use Autonumber as the key field and when the error pops up the record number is still not set. When I continue typing after the error the record number is set.

I'd be willing to email you the database file if you would be so kind to take a look. It's only 100K after zipping . The layout is pretty simple and straightforward so I can't imagine what's happening here.

My email is mike-palmerATmsnDOTcom (where AT=@ and DOT=.)

Thanks for your help.
 
I tried the sample and clicking on the button it says "Can't go the specified record". I'm using Access 2002 if that would make any difference.
 
That works - sorry before I was running the sample out of the zip file and it was read only!

The sample is a bit different from what I'm doing - my subform is shown in form view, not as a table.

I tried to add the databse here as an attachment, but it's just a tad too big.... can I email it to you?
 
My subform Default view is not as table. It is as Continuous Forms
I changed Default view as form and it still working.

You can send it to micsak@itsi.gr

Regards
 

Users who are viewing this thread

Back
Top Bottom