Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add new Records in Sub Forms

Status
Not open for further replies.

drkestrel

MIS
Sep 25, 2000
439
GB
The following works when I was using Access 97, but now that I have upgraded to Access 2000, the following doesn't:
Code:
Me.childDetails.Form.RecordsetClone.AddNew 
Me.refresh
Me.repaint
Me.childDetails.Form.refresh
Me.ChildDetails.Form.repaint

Basically, I have a main form(referred to as Me) whose datasource is Table A, and subform named as childDetails in the main form whose data source is Table B. The main form and subform are linked through child master field on two fields from Tables A and B.
I want the above code to basically add a new record in Table B which is linked to the subform on invoking the above code from the Main form.

At Access 2000, it just wouldn't add any new records to the subform and the current record is ALWAYS set to the first record.
Code:
Me.childDetails.Form.bookmark = Me.childDetails.Form.RecordsetClone.Bookmark
does not help either, except that it causes asn error "Field locked and not updatable" when I attempt to close the form.

codes like
Code:
DoCmd.GoToRecord acDataForm, Me.childDetails, acNewRec
causes compilation error, as does
Code:
DoCmd.GoToRecord acDataForm, Forms![frmLinkedtoTabA.Form]![frmLinktedtoTabB].Form, acNewRec
.

Any suggestions as to How I could navigate/add new records on a subform from a main form?

 
Try setting focus to the subform.

'add record to sub form
Me![Yoursubform].SetFocus
DoCmd.GoToRecord , , acNewRec

'assign a value to a field in that sub form
Me![Yoursubform].Form![DrawingNumber] = ActiveXCtl1.FileName

'save the record
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

' Requery the sub form
Me![Yoursubform].Requery



DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top