add a record subform

G

Guest

I have a individual account form with two subforms, both attached to my
Journal table. The purpose of the top subform is to add a journal record,
and the purpose of the bottom subform is to list the journal record entries
for edit or deletion in descending order by date.

(I created the layout this way so that the user can enter new journal
records without scrolling to the bottom of the list to enter a new record)

This method still has two problems

1. I have created an "Add" button in the top subform to officially "enter"
the record, but when this button is clicked, I would also like to refresh the
bottom subform to show the newly entered record.

2. If the user presses the tab button after entering a new journal record,
the record is entered automatically. I only want the record to be entered
when the user presses the "Add" button.

Please be clear with any code suggestions, as I'm and not very used to
writing code in Access (I'm used to doing VB code for ASP websites)

Thanks, Amanda
 
J

John Vinson

I have a individual account form with two subforms, both attached to my
Journal table. The purpose of the top subform is to add a journal record,
and the purpose of the bottom subform is to list the journal record entries
for edit or deletion in descending order by date.

(I created the layout this way so that the user can enter new journal
records without scrolling to the bottom of the list to enter a new record)

This method still has two problems

1. I have created an "Add" button in the top subform to officially "enter"
the record, but when this button is clicked, I would also like to refresh the
bottom subform to show the newly entered record.

2. If the user presses the tab button after entering a new journal record,
the record is entered automatically. I only want the record to be entered
when the user presses the "Add" button.

Please be clear with any code suggestions, as I'm and not very used to
writing code in Access (I'm used to doing VB code for ASP websites)

I'd suggest setting the properties of the upper subform to:

Data Entry = Yes
Allow Deletions = No
Cycle = Current Record

This will display *only* the empty "new" record or the record that has
just been added; and when the user tabs through the last control in
the tab order it will cycle back to the first rather than saving the
record and going on to a NEW new record.

In the first subform's AfterInsert event put the following line of
code. Click the ... icon by the After Insert event and invoke the Code
Builder; Access will give you the Sub and End Sub lines automatically.
You can also put this line of code in the Add button's Click event
instead, but the AfterInsert event will always fire whether the user
uses the add button or hits Ctrl-Enter or otherwise saves the record:

Private Sub Form_AfterInsert()
Parent!secondsubformname.Requery
End Sub


John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top