Repeating entries on form

D

DougW

I'm very novice at Access and could use some help.
I have created a form with a number of list boxes for ease of data entry.
The user clicks on several selections (such as Purchase Order and Component
number),
and also enters a couple of fields (Cost and Date). These inputs populate a
record in a table.
There is a command button to add a new record. So far all of this works.

Very often the user will be creating numerous records that are identical -
maybe 6 entries in a row of all the same data. I found some info on this
site that causes the various fields to retain their previous entry as default
(on the AfterUpdate event I added code "me.control.defaultvalue=me.control.
value").
That works fine too.

My problem is, I can't simply click my "new record" command button six times
in a row to create six new identical records. I have to edit one of my
fields or re-click a list box to make the form "wake up" before I can add a
new record.

What kind of event coding can I add to make this work the way I want? Thanks.
 
D

DougW

The click event code is as follows:

Private Sub Add_record_Click()
On Error GoTo Err_Add_record_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_record_Click:
Exit Sub

Err_Add_record_Click:
MsgBox Err.Description
Resume Exit_Add_record_Click

End Sub


--- thanks, Doug
What is the code in the click event of your new record button?
I'm very novice at Access and could use some help.
I have created a form with a number of list boxes for ease of data entry.
[quoted text clipped - 17 lines]
What kind of event coding can I add to make this work the way I want? Thanks
 
K

Klatuu

Clicking it repeatedly will not work.
The GotoRecord method will cause the current record to save, but the problem
is, the default values have yet to be applied. They are not applied until
the form becomes Dirty. That occurs when the first character is typed into
any bound control on the form.
As an experiment
Click your button.
You will see a blank form.
Type all the info needed in the form
Click the button again.
You will see a blank form.
Type a character into a bound control
The values typed in in the previous record will appear in the controls
where you set the default values.

Now, when you click the button again you will see a blank form
--
Dave Hargis, Microsoft Access MVP


DougW said:
The click event code is as follows:

Private Sub Add_record_Click()
On Error GoTo Err_Add_record_Click


DoCmd.GoToRecord , , acNewRec

Exit_Add_record_Click:
Exit Sub

Err_Add_record_Click:
MsgBox Err.Description
Resume Exit_Add_record_Click

End Sub


--- thanks, Doug
What is the code in the click event of your new record button?
I'm very novice at Access and could use some help.
I have created a form with a number of list boxes for ease of data entry.
[quoted text clipped - 17 lines]
What kind of event coding can I add to make this work the way I want? Thanks
 
D

DougW

Thanks for the info.
Do you think there's another way I could make it re-apply the default values
after I save a record?
Clicking it repeatedly will not work.
The GotoRecord method will cause the current record to save, but the problem
is, the default values have yet to be applied. They are not applied until
the form becomes Dirty. That occurs when the first character is typed into
any bound control on the form.
As an experiment
Click your button.
You will see a blank form.
Type all the info needed in the form
Click the button again.
You will see a blank form.
Type a character into a bound control
The values typed in in the previous record will appear in the controls
where you set the default values.

Now, when you click the button again you will see a blank form
The click event code is as follows:
[quoted text clipped - 20 lines]
 
K

Klatuu

Oh, yeah. I thought about that earlier, but forgot to mention it.
A control's After Update event doesn't fire until something is changed in
the control. So after the first entry, the Default value will be applied,
but not after subsequent new records.
Use the Form's After Update event to set the default value instead of the
controls after update.
--
Dave Hargis, Microsoft Access MVP


DougW said:
Thanks for the info.
Do you think there's another way I could make it re-apply the default values
after I save a record?
Clicking it repeatedly will not work.
The GotoRecord method will cause the current record to save, but the problem
is, the default values have yet to be applied. They are not applied until
the form becomes Dirty. That occurs when the first character is typed into
any bound control on the form.
As an experiment
Click your button.
You will see a blank form.
Type all the info needed in the form
Click the button again.
You will see a blank form.
Type a character into a bound control
The values typed in in the previous record will appear in the controls
where you set the default values.

Now, when you click the button again you will see a blank form
The click event code is as follows:
[quoted text clipped - 20 lines]
What kind of event coding can I add to make this work the way I want? Thanks
 
D

DougW

Okay - I moved all the default value statements into the AfterUpdate section
of the Form properties.
That does fill in all the text boxes with the defaults (the previous value).
They no longer blank out as they were doing previously.
Definitely getting closer!
However I still don't get multiple records from multiple clicks on the Add
Record icon.
After I click the Add Record icon it remains highlighted (the graphic is
surrounded by a dashed line rectangle). I have two list boxes of selections
(Purchase Orders and Components), and these selections fill in two of the
bound text boxes. These text boxes are successfully maintaining the value
from the previous record. However it seems I have to re-click on one of my
two lists to be able to create another record. I guess clicking on my list
selection is another way of making the table "dirty"?

And thanks again for taking the time to help me on this, I truly appreciate
it.

-- Doug
Oh, yeah. I thought about that earlier, but forgot to mention it.
A control's After Update event doesn't fire until something is changed in
the control. So after the first entry, the Default value will be applied,
but not after subsequent new records.
Use the Form's After Update event to set the default value instead of the
controls after update.
Thanks for the info.
Do you think there's another way I could make it re-apply the default values
[quoted text clipped - 21 lines]
 
K

Klatuu

That would be correct. You have to do something that will actually create a
new record. Going to a new record doesn't create the record until you put
something in it.

--
Dave Hargis, Microsoft Access MVP


DougW said:
Okay - I moved all the default value statements into the AfterUpdate section
of the Form properties.
That does fill in all the text boxes with the defaults (the previous value).
They no longer blank out as they were doing previously.
Definitely getting closer!
However I still don't get multiple records from multiple clicks on the Add
Record icon.
After I click the Add Record icon it remains highlighted (the graphic is
surrounded by a dashed line rectangle). I have two list boxes of selections
(Purchase Orders and Components), and these selections fill in two of the
bound text boxes. These text boxes are successfully maintaining the value
from the previous record. However it seems I have to re-click on one of my
two lists to be able to create another record. I guess clicking on my list
selection is another way of making the table "dirty"?

And thanks again for taking the time to help me on this, I truly appreciate
it.

-- Doug
Oh, yeah. I thought about that earlier, but forgot to mention it.
A control's After Update event doesn't fire until something is changed in
the control. So after the first entry, the Default value will be applied,
but not after subsequent new records.
Use the Form's After Update event to set the default value instead of the
controls after update.
Thanks for the info.
Do you think there's another way I could make it re-apply the default values
[quoted text clipped - 21 lines]
What kind of event coding can I add to make this work the way I want? Thanks
 

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