Record Selectors VS Combo Box Record Selector

G

Guest

I have a form that uses a BeforeUpdate event procedure and VBA to edit data
and insist that minimum data standards be used when updating/createing a
record. When I use the record navigation buttons it ignors the edit routine
and does not process records with invalid data from the past. When I use a
combo box to select a new record it calls the edit routine. The code for the
combo box is:

Private Sub LookupContactLast_AfterUpdate()
Form_BeforeUpdate (1)
If StopCond = True Then
StopCond = False
GoTo Exit_LookupContactLast_AfterUpdate
End If
Me.RecordsetClone.FindFirst " [ID] = " & Me![LookupContactLast]
Me.Bookmark = Me.RecordsetClone.Bookmark
ContactLast.SetFocus
Exit_LookupContactLast_AfterUpdate:
Exit Sub
End Sub

StopCond is a Public binary variable that is set to true in the sub
procedure Form_BeforeUpdate if any data editing condition fails.
LookupContactLast is the combo box used to select another record for display.

Why do the record selector buttons ignor procedure Form_BeforeUpdate() if
the data in a record would otherwise fail edits (many garbage records from
the past) yet does invoke the Form_BeforeUpdate() edit procedure when using
the combo box to navigate to another record?

Earl Phillips
Ex Mainframer Learning Access
Local Community Food Bank Volunteer
 
D

Douglas J. Steele

Unless you've changed something in the row, the BeforeUpdate event never
fires.

If you want to trap bad existing data, put the check in the form's Current
event. You can use the form's NewRecord property to ensure that the code
doesn't fire when you move past the existing data to a new row.
 
G

Guest

The form's Before Update event does not fire until the form has been dirtied
and you attempt to navigate away from it.
When you are using the nav buttons, not data gets changed, so the form is
not dirty, so the Before Update event never fires.
Your combo is explicitly calling the Before Update Sub. That is why it
fires there. If you want to perform edits on every record as you go through
the table with the nav buttons, use the Current evet to call the Before
Update as you are doing now.
 
R

ruralguy via AccessMonster.com

You only get a Form BeforeUpdate event when the form is *Dirty* and you
attempt to navigate away from the record of close the form. If you are
trying to clean up an existing table slowly as it is used then you may want
to use the Form's Current event instead. You may also wish to review this
link:

How to programmatically implement a RecordExit event in Access 2002
http://support.microsoft.com/default.aspx?scid=kb;en-us;304139
I have a form that uses a BeforeUpdate event procedure and VBA to edit data
and insist that minimum data standards be used when updating/createing a
record. When I use the record navigation buttons it ignors the edit routine
and does not process records with invalid data from the past. When I use a
combo box to select a new record it calls the edit routine. The code for the
combo box is:

Private Sub LookupContactLast_AfterUpdate()
Form_BeforeUpdate (1)
If StopCond = True Then
StopCond = False
GoTo Exit_LookupContactLast_AfterUpdate
End If
Me.RecordsetClone.FindFirst " [ID] = " & Me![LookupContactLast]
Me.Bookmark = Me.RecordsetClone.Bookmark
ContactLast.SetFocus
Exit_LookupContactLast_AfterUpdate:
Exit Sub
End Sub

StopCond is a Public binary variable that is set to true in the sub
procedure Form_BeforeUpdate if any data editing condition fails.
LookupContactLast is the combo box used to select another record for display.

Why do the record selector buttons ignor procedure Form_BeforeUpdate() if
the data in a record would otherwise fail edits (many garbage records from
the past) yet does invoke the Form_BeforeUpdate() edit procedure when using
the combo box to navigate to another record?

Earl Phillips
Ex Mainframer Learning Access
Local Community Food Bank Volunteer
 
G

Guest

Thanks, everyone, for your help. Now I know how they work so I can set up my
code to react exactly as I want it to react, and I will know why it is
reacting that way. Initially I will leave it as it is until almost all old
records are corrected. Later I will change it so they must correct the data
to move on.
Earl Phillips
Ex-Mainframer Grateful for the Help With Access
Harvesters Community Food Bank
Kansas City
--
Trying To Feed The Hungry


Klatuu said:
The form's Before Update event does not fire until the form has been dirtied
and you attempt to navigate away from it.
When you are using the nav buttons, not data gets changed, so the form is
not dirty, so the Before Update event never fires.
Your combo is explicitly calling the Before Update Sub. That is why it
fires there. If you want to perform edits on every record as you go through
the table with the nav buttons, use the Current evet to call the Before
Update as you are doing now.

EarlCPhillips said:
I have a form that uses a BeforeUpdate event procedure and VBA to edit data
and insist that minimum data standards be used when updating/createing a
record. When I use the record navigation buttons it ignors the edit routine
and does not process records with invalid data from the past. When I use a
combo box to select a new record it calls the edit routine. The code for the
combo box is:

Private Sub LookupContactLast_AfterUpdate()
Form_BeforeUpdate (1)
If StopCond = True Then
StopCond = False
GoTo Exit_LookupContactLast_AfterUpdate
End If
Me.RecordsetClone.FindFirst " [ID] = " & Me![LookupContactLast]
Me.Bookmark = Me.RecordsetClone.Bookmark
ContactLast.SetFocus
Exit_LookupContactLast_AfterUpdate:
Exit Sub
End Sub

StopCond is a Public binary variable that is set to true in the sub
procedure Form_BeforeUpdate if any data editing condition fails.
LookupContactLast is the combo box used to select another record for display.

Why do the record selector buttons ignor procedure Form_BeforeUpdate() if
the data in a record would otherwise fail edits (many garbage records from
the past) yet does invoke the Form_BeforeUpdate() edit procedure when using
the combo box to navigate to another record?

Earl Phillips
Ex Mainframer Learning Access
Local Community Food Bank Volunteer
 

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