Form view - data disappears on tab

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)
 
S

Steve Schapel

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.
 
R

Rob Parker

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
 
S

sbkris10

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
 
R

Rob Parker

What you report seems (to me) to confirm that there's something else
happening.

Rob
 

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