Form view - data disappears on tab

  • Thread starter Thread starter sbkris10
  • Start date Start date
S

sbkris10

I entered the following code (After Update event procedure) for
capitalization of "Guest_Name" which is a text field, but in form view,
after entering the guest's name and then hitting tab, the data disappears
from the screen. New to access & don't know what to do...

Dim Guest_Name As Control

Set Guest_Name = Me.ActiveControl

Guest_Name = StrConv(Guest_Name, vbProperCase)
 
Sbkris,

There is no need for the Dim and Set lines. In fact, you have confused
matters, because then you have a variable which you have named
Guest_Name as well as a control named Guest_Name, and probably also a
field named Guest_Name.

All you need in the AfterUpdate event of the Guest_Name textbox is:
Me.Guest_Name = StrConv(Me.Guest_Name, vbProperCase)
Just drop the other stuff.
 
The code you posted works fine for me (even with the extraneous code - see
following). I'm assuming that when you say AfterUpdate event, you mean the
textbox's event, not the form's event. You can do this with a single line
of code; two of your statements are unnecessary, and the following should
work as expected:

Private Sub Guest_Name_AfterUpdate()
Guest_Name = StrConv(Guest_Name, vbProperCase)
End Sub

If it doesn't then look elsewhere in your code; there must be something else
happening.

HTH,

Rob
 
Thanks guys.

The data is still disappearing from the field (form view) on tab, even after
I changed the code to your suggestions. However, the data is visible after I
save the record and go back to it. Hhhhmmm...at least it shows up after save
and is visible on reports as well.

-Kristen
 
Back
Top