Alternative to AfterUpdate?

  • Thread starter Thread starter GD
  • Start date Start date
G

GD

I have a form that uses the AfterUpdate event procedure to make several areas
visible or invisible. Example:

Private Sub txtFergusonChargeback__AfterUpdate()
If Me.txtFergusonChargeback_ <> "" Then
Me.txtEntryDate = Date
Else
Me.txtEntryDate = ""
End If
End Sub

Private Sub Form_Current()
If Me.txtFergusonChargeback_ <> "" Then
Me.txtEntryDate = Date
Else
Me.txtEntryDate = ""
End If

End Sub

However, this is not exactly what I'm looking for. Basically, I need for
the date to appear if there is any entry in txtFergusonChargeback_, not just
after it's updated. What event do I use for that?
 
When your form loads up a record, you want the AfterUpdate event on that
control to fire, right?

So you could add something like the following to the Form's OnCurrent event:

Call txtFergusonChargeback_AfterUpdate()

(by the way, if you've named that control to reflect the underlying field,
it would appear you have data -- "Ferguson" -- embedded in your field name.
This is not a good idea in a well-normalized relational database.)

Good luck!

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
So, instead of repeating the code in the Form's OnCurrent event, I'd enter
Call txtFergusonChargeback_AfterUpdate()?
 
Given he's already got the same code in the Current event, I'm suspecting
there may be something else going on here, Jeff.

I do agree with you, though, that he should be calling the AfterUpdate
routine from the Currnet event so as not to have duplicated code.
 
So, instead of repeating the code in the Form's OnCurrent event,
I'd enter Call txtFergusonChargeback_AfterUpdate()?

You could do that, but I'd suggest taking the code in
txtFergusonChargeback_AfterUpdate and moving it to a standalone
subroutine in the form's module and calling that subroutine from
both txtFergusonChargeback_AfterUpdate and OnCurrent.
 
Back
Top