Solved

Change a filed from visible to invisible on a form

Posted on 2013-01-07
6
255 Views
Last Modified: 2013-01-07
I am using a continuous form.  depending on a field in the same record I need to make the field invisible.   All the fields become invisible, not just the one that I selected.
ex: if Field1 = Completed then make Field2, which is STOP to invisible.
0
Comment
Question by:Startrac98
  • 3
  • 2
6 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 38750869
That's not going to work out on a continuous form... all records will either have the textbox visible or hidden.

You CAN however, use conditional formatting to enable/disable that field.

Under conditional formatting for the field you want to change:

-  Select Expression IS from the drop down.
- Enter the following expression in the space provided:
        [Field1] = "Completed"
- Choose disabled for your formatting for this criteria
0
 
LVL 61

Expert Comment

by:mbizup
ID: 38750887
Alternatively, you can use conditional formatting to set the text and background colors of the field to match so that the field appears hidden under that condition and use code in your form's current event to prevent the user from editing it:

Private Sub Form_Current()
   Me.Field2.Locked = ([Field1] = "Completed")
End Sub

Open in new window

0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38751003
In addition to mbizup's comment about locking the field in the Current Event, you could use the GotFocus event of the control to actually shift the focus to another control if [Field1] is completed.

If you use conditional formatting to simply change the foreground and background colors of the control, it can still get the focus, and if it gets the focus, the user can still see the value by highlighting all of the text in the control.  If, however, you use the GotFocus event to shift the focus to another control, they will not be able to do this.
Private Sub txt_Field2_GotFocus

    if [Field1] = "Completed" Then me.txt_Field2.Setfocus

End Sub

Open in new window

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 61

Expert Comment

by:mbizup
ID: 38751018
<<
it can still get the focus, and if it gets the focus, the user can still see the value by highlighting all of the text in the control
>>

Dale,

 I haven't tested this, but I think that locking/disabling the control through the current event would prevent this.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38751045
Miriam,

Disabling (Yes), Locking (No), Changing Fore/Back Colors (No).

Actually, I have used the changing fore/background color technique in the past, because my client did not even want my users to see the "hidden" fields if certain conditions existed.  However, when I did this, I encountered the situation that even though the control was not "visible" (same color as the detail background), I could click into it and if I highlighted the text it was readable.

Yes, you could also lock it, but I simply preferred to shift the focus out of that control immediately upon it getting the focus.
0
 

Author Closing Comment

by:Startrac98
ID: 38751371
Thank you.  Worked out perfect.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now