Update and reset fields to O

  • Thread starter Thread starter BYoung via AccessMonster.com
  • Start date Start date
B

BYoung via AccessMonster.com

I have a tabular form based on a table, tblDPG. Employees will get into this
form and enter data into 6 fields

chrTechNumber
dtmWorkDate
numJobsAssigned
numJobsComplete
numPoints
numHours

after the employee enters information I want them to click an update button
to update the information in the table and reset the fields back to 0. Here
is the code I have now.

Private Sub cmdUpdate_Click()
If Me.Dirty Then
Me.Dirty = Flase
End If

me.chrtechnumber.value = "0"
me.dtmWorkDate.value="0"
me.numjobsassigned.value="0"
me.numjobscomplete.value="0"
me.numPoints.Value="0"
me.numHours.Value = "0"

The problem is that this updates the information and resets the values in the
first record only to 0, while at the same time changing the information in
the table to 0 also. I would like for this command to store the information
in the table and then reset the values on the form to zero.

I'm pretty new to VBA so I'm not sure how to do this successfully. Any Ideas?
 
The problem is that this updates the information and resets the values in the
first record only to 0, while at the same time changing the information in
the table to 0 also. I would like for this command to store the information
in the table and then reset the values on the form to zero.

Ummmmm...

WHY!?

You don't need *any* code to update the table. Just moving off the
record will update the table.

You don't need to set the fields to zero. you can just move to the
"new" record, and they'll all be set to NULL, or to their DefaultValue
property.

You're making it much harder than it needs to be! Just leave the Cycle
property of the form to All Records (the default), and (if you wish)
set the DefaultValue properties of the controls to 0. When the user
enters the last control's data, it will go to the new record and show
all zeros. No code at all!

John W. Vinson[MVP]
 
When my managers open the form it needs to be completely blank, I don't want
them to see any existing records on this form. I guess I really don't need
an update button, just like what you said, when someone updates information
and exits out of the form it stores the records correct? Now if I set the
properties to dataentry=yes then won't all the fields be clear when someone
opens the form? The big thing is that this is a data entry tool, not a data
viewing tool.

Thoughts?
 
When my managers open the form it needs to be completely blank, I don't want
them to see any existing records on this form. I guess I really don't need
an update button, just like what you said, when someone updates information
and exits out of the form it stores the records correct? Now if I set the
properties to dataentry=yes then won't all the fields be clear when someone
opens the form? The big thing is that this is a data entry tool, not a data
viewing tool.

Thoughts?

You're quite correct. Set the form's Data Entry property to True, and
that's what you'll get. They can review the data that they have
entered during that session, but not see any older records.

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

Back
Top