3
votes

I recently got help on When select value from combo, highlight that record in Access subform datasheet and now I'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.

4

4 Answers

3
votes

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.

1
votes

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.

0
votes

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.

0
votes

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