Link to home
Start Free TrialLog in
Avatar of mdanny
mdanny

asked on

Cancel MSAccess message on status bar.

I have a calculated textbox control on my form.Is it possible to make custom message or just cancel alltogether the annoying message on status bar "Control can't be edited because it's bound bla.. bla. .bla.. " when I try to type in the textbox?
Avatar of BrianWren
BrianWren

Is your form single of continuous?

What part of the form is the control in:  Header/footer, or Detail?

Brian
Avatar of mdanny

ASKER

single form detail section
I'm not sure of any way to prevent that message from coming up in the status bar. It doesn't throw a trappable error or anything. Maybe someone else knows.

I suspect that what you need to do is to set the Enabled property to "No" and the Locked Property to "Yes" on the controls Data tab. That way the user can't even get into the control to see the message. If it's a calculated control I can't think of any reason the user would need to get into the control.
In the OnCurrent event of the form, fill in the text box with the value that you are currently setting the ControlSource to:


Private Sub Form_Current()
  Me!fld = <calculation>
End Sub


Leave the Control source of the text box empty.

The reason I asked if it was Single or continuous is that if you do this on a continuous form, all of the controls in that column get the same contents.  On a single form that's not a problem.

Then, since the control is not 'hard coded,' Access will let yo uchange the value.

Brian
To clear the message you could do this
Dim ss As Variant
ss = SysCmd(acSysCmdClearStatus)

To add messages
ss = SysCmd(acSysCmdSetStatus, "Your message")

but I do not think you can trap the first instance of the message getting on the status bar.
You could maybe put the code in the focus event of the control that makes the message appear..I will have to try it.
mdanny,

Is your problem solved?

Brian
Avatar of mdanny

ASKER

To All :
Sorry I was ill for a while so I'm a bit late with my reaction.
 
To Tuck:Which event should trigger this function?
To BrianWren:
Sorry single form was a sample form I tried on.The actual form is continuous.
To jschrisman:
You're right.What I did was to set enabled=false.
But on some controls I have to use click
event so this I still don't know how to achieve.
Does the user need to be able to actually access this control, or do they just need to be able to read it?

(Glad you're feeling better!)

Brian
OK, I've got another solution. Reset the enabled property to true and set the locked locked property to true.

Remove the formula from the control source property; making the control unbound.

In the forms OnCurrent event, set the value of the control to the formula. Also remember if there are any other controls on the form that the formula depends on you will have to reset the formula on those controls AfterUpdate event.

The sample source is from a form with 2 controls. The Text0 control is the one that is locked and enabled; it is also the one that is calculated.

Option Compare Database
Option Explicit

Private Sub Form_Current()
Text0 = Text4 * 10
End Sub

Private Sub Text0_Click()
Debug.Print "Click"
End Sub

Private Sub Text4_AfterUpdate()
Text0 = Text4 * 10
End Sub

Hope this solves the problem for you.
Setting the control's contents this way will cause each visible control to have the same results--the results for the current record...

(That's why I asked in the first place whether the form was single or continuous.)

Brian
Woops. Good point, Brian.
I would put what I suggested in the GotFocus event of the control or controls.
Avatar of mdanny

ASKER

To tuck.Tried it doesn't work.Sorry
You can put the code to clear the status bar in the On Timer event, and set the timeinterval to 0.  When it is 0, that event doesn't happen.  At the point where the error can show up, (like in the GotFocus, change the TimerInterval to 100 miliseconds, (Me.TimerInterval = 100)

When the error happens, 0.1 Sec later it will be cleared.  This will keep happening as long as there is a timerinterval.  

Then on LostFocus of the control, set the timerinterval back to 0, and that event will cease taking place.

Brian
Avatar of mdanny

ASKER

To BrianWren.Tried it.Doesn't work either.Sorry
What about hidding the status bar completely, when the form opens
Application.SetOption "Show Status Bar", False
when the form closes
Application.SetOption "Show Status Bar", True


Just an idea...
I don't think I read an answer to the question: do users need to be able to edit the control or just view it? If it's the latter, then why wouldn't the Enabled = No and Locked = Yes work? That will leave the control shown nicely but users won't be able to get into the field to do anything, and therefore can't see the message . . .
Avatar of mdanny

ASKER

to brewdog : I need to use the click event
They can click a control that is enabled and locked.

Or you could set Enabled = No and Locked = Yes an put a transparent object over the top of it to receive the mouse click.

(I like the second best, becaue it will intercept everything you try to do to the contents of the control using the mouse, and you can't get into the control using the keyboard.  The message never appears, because no way to edit it exists.

Brian
That's what I was thinking, too, Brian . . . but will Access let an invisible control receive a click event?
ASKER CERTIFIED SOLUTION
Avatar of BrianWren
BrianWren

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ah, you're right. My bad. :o)
any news here, mdanny?