Solved

How should I make a label visible over a textbox when condition met?

Posted on 2004-05-02
10
715 Views
Last Modified: 2009-07-29
I have a form where I put a label with a message over a textbox. The idea is to have the label become visible and block out the textbox when a certain condition is met. Otherwise, the label is not visible and the record’s information in the textbox is visible.

The textbox is on a subform displaying data for records selected in the main form. The subroutine is working when I use a message box, but I like the idea of the label showing on top of the textbox so they are always together no matter where the user moves the window to and also so the user does not have to click a button to get rid of the MsgBox. The label is on top of the textbox just to alert the user that there are no records in the subform recordsource for the primary recordsource in the main form.

I placed the label on top of the textbox and made it invisible (format "on-top") and then turn on the visibility with a sub procedure. However, when the procedure runs it appears that the textbox has priority to be visible. I tried making the textbox invisible, but I get an error that the procedure cannot make the control invisible when it has the focus.

Any suggestions?
0
Comment
Question by:richardlh
  • 4
  • 2
  • 2
  • +1
10 Comments
 
LVL 27

Expert Comment

by:jjafferr
ID: 10971383
Hi richardlh,

make the Textbox invisible and the Lable visible,
me.Textbox.visible=false
me.Lable.visible=True

Hope this helps

Jaffer
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 10971387
richardlh,
didn't see the last part,

try

me.Lable.setfocus
me.Textbox.visible=false
me.Lable.visible=True

jaffer
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 10971433
I think the best idea is to use conditional formatting then you don't need to use code at all.
When the condition is fulfilled have it that the text box is disabled & another textbox shows up (on the main form) with the message that you require.
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 27

Expert Comment

by:jjafferr
ID: 10971461
tbsgadi
Conditional formating does not allow for visible/invisible

Yes you can use Conditional formating if you have a white background for example, so make your default text color as white, and when your condition is met, change the Font color to something else.

jaffer
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 10971491
That's exactly what I meant for the other textbox,but I wrote to disable the the original textbox (which it does do)
0
 
LVL 11

Accepted Solution

by:
Mighty_Silly earned 250 total points
ID: 10971851
Greetings all,

Hi Richard,

It is correct that you get the error IF the field you want to make invisible has the focus (the cursor is there).  And I don't think (mabbe I am wrong) that Labels cannot receive focus.

What I normally do is instead of using a Label I use an Unbound Textbox for this.  Make it invisible/Enabled/Locked by default.  Then my code do this in order:
-If condition is True and I want to display message:
  -make textbox Invisible = True
  -Setfocus to THIS textbox (Quasi-label)
  -make the REAL textbox Invisible = False
-Reverse the process for when condition is False so your REAL text box show again.

-Silly-
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 10972079
You are right Mighty_Silly
you cannot set focus to a Label,
thus the focus should be set to the next Textbox

jaffer
0
 

Author Comment

by:richardlh
ID: 10972690
Ah yes, use an unbound textbox with a [= "Text goes here statement"] then shift the focus to the one made visible and the other textbox, make it invisible. I will try that and post the results. Thanks for the quick response. Back in a little while.

Have a great day :-), Richard
0
 

Author Comment

by:richardlh
ID: 10972892
Mighty Silly,

Converting the label to a textbox, seting the focus to it, and controling the visible property did the trick. Thanks a bunch and I hope to help others with their questions with Access and VBA as I gain more knowledge and experience.

Regards, Richard

0
 
LVL 11

Expert Comment

by:Mighty_Silly
ID: 10972950
You're very welcome Richard!  Glad I could help.

Sites like this have truly widen my knowledge in various topics, and I have no doubt I'll continue to learn from other Experts from this site.

By keeping an open mind I continue to learn various ways to achieve desired result, thus enabling me to select the "most suitable" solution for a particular situation.

Thanks for the Points award.

-Silly-
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

816 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

11 Experts available now in Live!

Get 1:1 Help Now