I have a conditional format that colors the combobox's background color depending on its value. The combobox is within a subform (if that matters; it shouldn't). For some reason, the conditional format only applies when the combobox has focus. Can anyone tell me what might be going on? I'm assuming this isn't supposed to happen, since I had almost the exact same setup with a text box and the background color is correct whether it has focus or not.
Also my combobox has its rowsource determined by a query in VBA due to a Form_Current() event in case that has anything to do with it (when I comment out the line I have the same problem though).
Thanks!
A combobox or textbox with a transparent background shows its background color (default or conditionally formatted) only when it has the focus.
Solution: set its BackStyle to Normal.
Sometimes the answer is much simpler than expected. :-)
Related
I want to show a placeholder in a ComboBox if no values has yet been selected or the previously selected one has been removed / deselected. For single-column ComboBoxes that works like a charm using #;"My placeholder" as the Format of the ComboBox. So far so good.
The problem starts if my ComboBox has more than one column. How can you set the placeholder value for a multi-column ComboBox? More general: How can you specify the Format for a multi-column ComboBox?
Is it for example possible to color the first column green and the second one red? And if it is possible, please tell me how.
I could not find any specification on how to set the format for multiple columns. Neither on MSDN nor on support.office.com.
P.S.: I do not care if a working solution relies on VBA or if it can achieved just by entering something in the layout or design view.
Sounds like you are outgrowing what a ComboBox can easily provide in Access.
First, combo options, and then my real suggestion.
Here are your ComboBox options:
Try conditional formatting, and see if you can get the combo's text box to change color if the value is null.
You could make a UNION query that appends your placeholder record to the top of your Combo's real recordsource
You could try to get your users used to the idea of 'blank' = null, and fix it with training.
I have never seen a way to do different combo column colors in Access.
My REAL suggestion:
Ditch the combo and go with a modal dialog form that pops up for the user. This will let you format everything much more closely to what you want.
You can put textboxes on your main form to display the placeholders.
The user clicks on the textbox to open your dialog form.
I have a form including listboxes. I'm trying to change order of listboxes. I tried bring front or send back but they are not working in form view. I found z index property for arranging their priority. However, following codes are not working. Is this correct way to do it? Or is there any other way with or without codes to do this?
Me.Controls.SetChildIndex (Me.List0 , Me.List1)
Thanks for any help.
Without using code:
You can change the z-order by right-clicking any control and selecting "Position" then selecting either "Bring to Front" or "Send to Back."
Unfortunately, Access does not support the ZOrder method for manipulation using code. Microsoft Forms does support the ZOrder method which can get confusing when it comes up on Access Help.
As I reread your question, I wonder if you're talking about tab order. If so, right-click and bring up "Properties," select the "Other" tab, then adjust the "Tab Index" property. Also, make sure that the "Tab Stop" property immediately beneath is set to "Yes." In code you would use FormName.ControlName.TabIndex=0 to set a control to the first tab position.
Hope this helps!
Reference: Personal experience (and hours of frustration)
docmd.RunCommand acCmdDesignView
forms("form1").Controls("text0").inselection=true
docmd.runcommand acCmdSendToBack '(or docmd.runcommand acCmdBringToFront)
docmd.RunCommand acCmdFormView
Also, ZOrder is still not supported by Access 2016. As such, I have not yet learned a way to write a single line of code that puts a control in between two others, I just send the middle to back and then the back to back, and expand this to however many controls have to overlap.
And last, even though you use the VBA for ZOrder, your English does ambiguously sound like forms("form1").Controls("text0").TabIndex=34, which as Olek suggested, is also quite simple.
I did this on one Access form: The control I wanted on top I just cut and pasted it back to the form, then moved it over the one I wanted to cover. In this case, it was a text box (bound), almost the same size as a combo box (unbound); only the dropdown of the combo extended a bit to the right of the text box, so when the form was loaded the text box looked like a combo box. The user clicked the dropdown and made a choice and the record(s) pulled up were reflected in the text box.
I think I'm looking directly at an Access 2003 bug. Here's what I did (I think):
I'm developing a Continuous Form (i.e. multiple records per page).
I have an unbound textbox in the background of the Details section. Under Data Properties, I have Enabled=No and Locked=Yes. (In other words, I don't want the user to select it. I only want it for the background color)
This textbox also has some conditional formatting to change the background color for that row. (e.g. If we haven't spoken to that customer in awhile, the background for that record is red)
If I choose a record where the conditional formatting is active (i.e. the background is red), I can actually click on this textbox. There's not much that I can do, of course, but this shouldn't happen and surely would be confusing to the end-users.
Has anyone else seen this? What's your workaround?
Enabled is a property that can be controlled via conditional formatting. By default when you add a new condition, the Enabled property is set to True. If you don't want your control to be enabled you must explicitly set Enabled = False within the conditional formatting rule.
The property is toggled via a button in the lower right corner of the conditional formatting dialog. It's easy to miss (I forget about it all the time).
Personally, I think the property should be three-way: True, False, or Inherit (with Inherit as the default). Unfortunately, Access forces you to be explicit when adding conditional formatting rules and state whether the rule should make the control Enabled or Disabled.
Here's my workaround (I was waiting to see if anyone else would suggest something better. Apparently not.)
In my conditionally formatted textbox, add an Event Procedure for GotFocus. Enter this code: Me.Txt_FocusHere.SetFocus.
Make a 2nd unbound text box somewhere on the form. Shrink it until it's just 1 line thick. Call it Txt_FocusHere.
So whenever the user clicks on the colored background, the focus is immediately taken to this dummy textbox which can't store any data and is so small that the user doesn't see the blinking cursor.
I successfully used the method on the following page: http://www.mvps.org/access/forms/frm0047.htm - "Changing the Background Color of the Current Record in a Continuous Form"
I'm having an argument with a co-worker, and I'm trying to convince him that it's a bad idea to change checkbox text (label) according to the checkbox state.
For example, we have a combobox that automatically picks selected value (and is disabled) when checkbox next to it is checked and is enabled when checkbox is cleared. His idea is to show Autoselect when checkbox is checked and Manual select when it's cleared. I'm sure that this will confuse the user as users tend to think that checking a checkbox next to a verb will make it true, only to find that the label has changed to something else.
What is your opinion on this matter?
P.S. I remember reading about changing checkbox text somewhere, in a book or blog article, but can't remember where. It would be great to have this in writing :-)
No need to mess with something that already works.
Changing the label would be horribly confusing and counter-intuitive, especially in the way you describe.
If the label describes the current state ("Manual select"), it will not be clear whether it is necessary to click on the checkbox to achieve the described state (like with a button), or whether it already is in that state.
A checkbox is a simple thing. When it is off, it does A. When it's on, it doesn't do A. The label needs to reflect what it does when it's turned on; it is then perfectly clear what doesn't happen when it is turned off.
If you want to show that the choice is between "Auto select" and "Manual select" then you should either reword your checkbox label or have a radio button:
o Manual Select
* Auto Select
Which isn't really ideal either.
But you shouldn't be changing the text on the label - the user won't remember what it was before and will be confused when it changes.
Personnaly i would say that the label shouldn't change.
From my experience changing the text is confusing, I have the same issue with modal buttons that change their text. It is hard to tell whether pushing the button will turn on the selected state or the text is the selected state.
Tick box text should not change.
Changing the text when the checkbox is checked changes the meaning. If it's checked and the label says Autoselect, I expect the Autoselect option to be enabled. If you uncheck, it's clear that the Autoselect option is NOT enabled. If you change the text to be Manual select whenever the checkbox is cleared I would expect that checking the box would enable the Manual select option. It's way too confusing if the text keeps changing.
You're right, he's wrong.
Checkbox labels should not change. That's part of the way checkboxes work.
See Should “toggle buttons” show what they do or the system status? on UXExchange for an alterantive approach using toggle buttons instead of checkboxes.
The label definitely shouldn't change. It's not only confusing, but it's unnecessary and ugly.
The only way I can think to make it less confusing would be to have the label state in brackets the current state, i.e. "Manual(currently auto)[]".
But that's really just a testiment to how ugly it gets.
Don't mess with what people are used to. Especially when you consider that if you do this, one will always be shown WITH a checkmark, and the other WITHOUT. Really confusing.
In the name of compromise, you COULD use a button instead, which toggles the control back and forth, and changes its value with each click.
Current mode: [Manual]
Still kind of confusing though. As I said, don't mess with what people are used to. It's like if you put a scrollbar on the left of the screen. It'll just mess with peoples' heads.
I would not change the checkbox label... I would have it say "automatic." But, depending on what your controls are actually doing, I might modify the selection in the grayed-out combo-box to reflect that it is now under automatic control.
Then to make the logic go both ways, if while the checkbox was unchecked, the user selected the "automatic" value in the combo-box, the checkbox would then become checked.
Or in another scenario:
If, when the "automatic" checkbox is checked, the automatic logic actually chooses a default value that is in the combo-box, then change the selection in the combo-box to show what the automatic setting actually is. The combo would not be editable, but it could be used to provide information about the actual setting that is being engaged.
I have a report in SQL Server Reporting Services which should show
a text box with a static text for "normal" users
a text box with a hyperlink to open up a new details windows for "super" users
The user level is determined by a parameter being passed into the report.
How can I achieve this? I tried to create a textbox with a text span inside that has a hyperlink, and then just leave it blank for "normal" users, but that doesn't seem to work reliably.
Is there a trick or method to get this to work? I'm thinking I need to add some code to the report to check the user level and then either insert a static text, or a text with a label, into that target textbox. But how do I do that (not having any VB/VBA/VB.NET experience....)
Thanks!
Marc
To make the hyperlink, you should be able to use an expression like
=iif(Parameters!IsSuperUser.Value = True, "http://some link","#")
in the Action property of the textbox, if you set the Action to "Jump to URL".
To control the content of the textbox, use a similar expression in the Value property.
(This is true on SSRS 2005 - I don't have access to 2008)
Edit
Unfortunately, hyperlinks in SSRS aren't formatted in a way to make it clear that they're hyperlinks. The only way to achieve this would be to add similar conditional formatting expression to the Color and TextDecoration attributes to make the field appear in a different colour and underlined when it is a hyperlink.
I haven't got SSRS installed on the machine that i'm writing this on so i can't give you an exact guaranteed bug free answer, but this answer should set you on the right track.
Have two textboxes, both located in the same absolute position (inside a container element if necessary). Fill them both with their correct values. Then just control their visibility by toggling their Hidden property with an expression:
=(Parameters!UserLevel.Value = 'Admin')
Obviously UserLevel is the name of the parameter being passed in to the report. The 'Admin' value is for illustrative purposes, personally i would use an int value to represent the user level, much like using an enum.
Remember that it is the Hidden property you are setting, so you have to reverse the logic you would have used if you were setting a Visible property :)