开发者

How to add new record to subform

I recently got help on When select value from combo, highlight that record in Access subform datasheet and now I开发者_Go百科'm trying to do a related task.

How can I make the subform give me a new row for data entry from a button on the main form?

Tried the method found here with no luck: http://www.access-programmers.co.uk/forums/showthread.php?t=26537

EDIT: Not sure if it matters, but the table my subform is supposed to update is a linked table to SQL Server.


Please first make sure your recordsource is updateable by opening the table or query in which your subform recordsource is based, and ensure that you can edit and add new records. If not, then it's possible that your SQL Server linked table is missing a unique indentifier. To create one, simply delete the linked table, and relink it. Upon relinking, MS Access should prompt you to specify a unique index (may take more than one field to make it truly unique). Then try again.


If the subform datasheet is editable and with AllowAdditions turned on, it should already give you the * button to add a new row.

If it doesn't, then you need to check the datasheet's properties and change them to match what you're actually seeking.


it has been a while since I used Access. Doesn't the RecordSource property of the subform give you the underlying table or query. If the source is editable, you should be able to add a record then Requery or Refresh the subform.


For those who need just to add a new record to sub form: just set focus from main form to subform. Then use DoCmd to add new record:

Forms![MainFormName]![SubFormName].SetFocus
DoCmd.GoToRecord , , acNewRec
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜