Controlling record entry in subform

G

GVR_Mike

Hi,

I have a form that contains a subform. The subform displays several
rows of detail data (in tabular format) that is related to the current
record on the main form.

Let's say that for a particular record in the main form, there are
three records of detail data. My subform shows those three rows of
detail data, but it also shows a forth row that is empty. If the user
enters a value into
any one of the fields in this row, a record is appended to my detail
table.

I would like more control of how a user appends a new row of detail
data. Ideally, I would like the user not to see any of the fields in
the forth (new) row unless he purposely clicks a button to add a new
row. This way, I
can put code in the On Click event to preload data into certain
fields.

I set the subform as AllowAdditions = False. The user clicks a button
to add a new record. The button On Click code sets AllowAdditions =
True, populates a couple of the fields and sets focus on the field in
which the user will enter data. The problem still remains that when it
sets AllowAdditions = True the blank new record shows up again. Is
there a way to hide this while still allowing the user to enter/edit
in existing records? (By this time I've populated some of the fields
so the subform record is already saved to the table).
 
R

Ragnar Midtskogen

You could use the subform just to display the related records by leaving the
AllowAdditions property as False.
Then, to allow the user to add records you place another subform, with the
same fields as the subform, just below the subform, or any other convenient
place for that matter.
This form should be unbased, that is it does not have a record source. When
the user wants to add data he fills in the second subform and clicks a
button. The code behind that button opens a recordset and adds the new
record to the table, including the index that links the two forms. You need
to requery the original subform to show the new record.
Ragnar
 
G

Guest

I tend to use popus for that kind of thing. It calls more attention to the
fact that you're doing something "different." I open it in Dialog mode so
that you can't do anything else until you close it, and then the code on the
original form takes over from there, so that a Requery can be issued on the
original subform (for example).
 

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