After Update question

  • Thread starter Thread starter Gary Schuldt
  • Start date Start date
G

Gary Schuldt

I have a txtName field in frmA which can contain multiple words.

AfterUpdate I want to capitalize all the words; I know how to do that.

However, I would like to allow the user to make changes after they see what
the AfterUpdate code did.

If they do make changes, will that raise the AfterUpdate event again? If
so, then I guess I need to nullify the event procedure after the first time
around, but I'm not sure how to code that.

Thanks.

Gary
 
It doesn't matter where he puts it, Tom. If the users change it, that's
going to generate new Before and After Update events.
 
Try using the Before Update Event. It makes a difference when I use it to
update the User and time fields in my records

Tom
 
OK, so I need to know how to procede, given that the events could recur.
I'm vaguely aware that there's a straightforward way to do it, I just don't
know what it is.

Gary
 
Gary Schuldt said:
OK, so I need to know how to procede, given that the events could recur.
I'm vaguely aware that there's a straightforward way to do it, I just don't
know what it is.

Instead of AfterUpdate why don't you just provide a CommandButton that does the
initial conversion and then the user simply doesn't press it the second time?
 
Gary Schuldt said:
OK, so I need to know how to procede, given that the events could
recur. I'm vaguely aware that there's a straightforward way to do it,
I just don't know what it is.

One possibility, Gary, is to perform the capitalization only if the
control's OldValue property is Null. For example,

Private Sub txtMyTextbox_AfterUpdate()

With Me!txtMyTextbox
If IsNull(.OldValue) Then
.Value = StrConv(.Value, vbProperCase)
End If
End With

End Sub
 
Thanks, Rick,

Actually, I used your approach with another control on the same form, and it
works fine . . . except I'm finding the user doesn't always press it!

So I wanted to explore another way that would automatically invoke the
procedure once; then, if they wanted to override it, they still should be
able to. So that's what I'm striving towards here.

Gary
 
Hi, Dirk,

that would catch the case when they are entering a new value but not if they
are changing an existing one, right?

Isn't there a way in VB to say something like:

Me!txtMyControl.AfterUpdate = Null

to mimic blanking out the AfterUpdate action you specify in the properties
dialog box?

Gary
 
Gary Schuldt said:
Hi, Dirk,

that would catch the case when they are entering a new value but not
if they are changing an existing one, right?

Right. Was that not what you wanted?
Isn't there a way in VB to say something like:

Me!txtMyControl.AfterUpdate = Null

to mimic blanking out the AfterUpdate action you specify in the
properties dialog box?

Yes, but you have to say:

Me!txtMyControl.AfterUpdate = ""

or


Me!txtMyControl.AfterUpdate = vbNullString

That will disable the AfterUpdate event for that control, until you
re-enable it by executing

Me!txtMyControl.AfterUpdate = "[Event Procedure]"

I'm not overly enamored of the idea, though -- I try to avoid making
design changes to forms at run time; besides, it probably won't work if
you ever convert your application to an MDE, though I admit I haven't
tested that. If you want finer control of the operation of the code in
the AfterUpdate event, I would use a module-level Boolean variable to
control it, setting that variable to True or False in appropriate events
and then testing it in the AfterUpdate event procedure to see whether
the body of the procedure should be executed.
 
Back
Top