visible

accessman2

Registered User.
Local time
Today, 15:05
Joined
Sep 15, 2005
Messages
335
Hi,
On the form,

I have one field called "Tax", when I open the form, the "Tax" is invisible, when I click one button, then the "Tax" is visible, after the input the value, I want the "Tax" to be invisible. But it cannot be invisible.

Private Sub Tax AfterUpdate()
[Tax].Visible = False
End Sub

How can I fix it? Thanks.
 
Hey AccessMan2,

You can not make Tax visibility False while it has the focus. You will need to move the focus some where else, After Update, and then set it's visible to false.

HTH,
Shane
 
I got it, but I don't want to fix the Field.

I want to do that, if I click the specific field , then the setforce is on that field. how can I do that.

Private Sub Tax_Exit(Cancel As Integer)
label_Tax.Visible = False
[Date Field].setforce // this one will go to [Date field]
[Tax].Visible = False

End Sub

I don't want to fix the field, I would like to do that if I click the field, then the setforce will be on that field.
How can i edit it? Thanks.
 
Hey AccessMan2,

I don't understand your question. What does "I got it, but I don't want to fix the Field" mean?

Shane
 
I mean that,

Does there have the code for that?
if the setforce is NOT on the [Tax] field, then the [Tax] will be invisible.

So, what command can do (if the setforce is NOT on the [Tax] field)?

Thanks.
 
This is very confusing... :confused:

First off, I'm not sure what you mean with setforce? I suppose you mean the focus, correct me if I'm wrom.

Now then, a field needs to receive the focus from somewhere, and when you leave the field (by pressing TAB or ENTER or clicking somewhere), the field looses it's focus. In these cases you can control the field's visibility.

So, in the OnExit-event of the control (field) before the tax-field, you need the add this code.

Code:
Me.Tax.Visible = True

This is the same code that you use with your button that makes the tax-field visible. If you want your button to be the only way to show the tax field, then forget about the above code.

Now, your original question was : how can I set Tax's visibility to false when I leave it? You received an error because, at the moment you ran your code, which was correct, the focus on your form was still on the Tax field. When a field has the focus, it cannot be hidden (like Shaneman already explained).

You need the shift the focus to the field you want to be focussed when you leave the Tax field. It can be any field or button on your form, except for the Tax-field.

Code:
Private Sub Tax_AfterUpdate()
Me.NameOfAnotherFieldOrButtonOnYourForm.SetFocus
Me.Tax.Visible = False
End Sub

Use the above code, and it should do the trick.

Good luck!

Seth
 
Darn shame AccessBoy2 refuses to search the forum before posting a question that has been asked and answered so many times before.
 

Users who are viewing this thread

Back
Top Bottom