I have created two reports in Access 2007 that are virtually identical except for the data source. In both of them I have set up conditional formatting on a field to make the font italic when
Expression is [Status]="Holding"
In one of the reports the conditional formatting is applied and in the other it isn't. I've even tried setting it to
Expression is [Status]=[Status]
but the conditional formatting still isn't applied. Any ideas on what is going wrong?
I cleared the conditional formatting from all the text boxes where it was set. I then again set the conditional formatting to
Expression is [Status]="Holding"
This time it worked! Very strange, but at least it's working now.
I found this helpful excerpt on the Office website:
Before you begin
When you use an expression to apply conditional formatting, you should make sure that > the controls being formatted do not use the same
names as any of the fields in the form's or report's underlying record
source. If you refer to a field in an expression and there is a
control by the same name on the form or report, Access is unable to
determine whether you are referring to the control or to the field.
Because of this, Access cannot evaluate the expression. As a result,
the conditional formatting is not applied, and the control appears
with its default formatting. Whenever you add expressions to a form or
report, it is very important that you rename any controls whose names
conflict with field names that are used in the expressions.
Be also careful with the 'BackStyle' property of the control. If you use a form wizard and default style template the backstyle may be transparent - which means that conditional formatting with a backcolor does nothing.
Related
I have a subform which makes a lot of use of conditional formatting to grey-out cells which cannot contain data, and highlight cells which have been adjusted by the user. The subform is a Datasheet.
This all works fine, except for the lag in applying the formatting, which sometimes even won't update until the user mouses over the cells.
What I would like to try is applying the formatting in VBA, rather than using the in-built conditional formatting, as I would rather the form takes a couple of seconds longer to load but with all formatting applied once it does, than to have the delay I'm currently getting.
So what I'm stuck on, is how to tie back a control on the subform to a specific record in the view that's populating it. For example, I can use the following code:
Dim ctrl As Control
For Each ctrl In Me.Controls
MsgBox ctrl.Name & " : " & ctrl.Value
Next ctrl
Which might display, for instance, "RowNumber : 010", so I could identify what record that control relates to, but when it says "TotalUSD : 1,234,567.89", I would have no way of knowing which record that related to, and therefore whether or not formatting should be applied.
Is there a better way of doing this, I guess ideally by being able to link each ctrl to its corresponding record in the Form.Recordset?
UPDATE
Below screenshot shows the conditional formatting as it is currently implemented, and what I am trying to achieve using VBA instead of conditional formatting.
I do not have in depth information about your implementation so here is a general suggestion that I have used in my implementations.
You should add some kind of distinguishing column to your table. For example I once had a form that showed projects and employees. The distinguishing column contained a boolean value "True" for each project, "False" for each employee. Based on that information I was able to format accordingly.
My suggestion: Add an integer distinguishing column to your recordset table. The value "0" would be a plain column, "1" would be for greyed out, "2" for user input.
In the Form_Load Event you would have to iterate through all your controls and set the formatting.
Im creating a report in RS2008.
Everytime I create a textbox and write an expression, instead of watching the expression text after I change focus of the element I get the following tag: <<Expr>>.
I'm used to creating reports on RS2005 and if in a textbox I wrote ="Hello", for example, once I change focus it will display ="Hello" not <<Expr>>.
Its probably a setting but I can't find how to change it.
I don't think you can change this - it's by design in SSRS 2008.
I would say the reasoning behind it is that you can now have multiple placeholders in one Textbox and it's easier to represent with multiple <<Expr>> values:
For text and basic field values, these will not have <<Expr>> displayed.
If you change basic text from ="Hello" to just Hello that's what will be displayed in the designer:
And an expression like =Fields!val1.Value will be displayed like this in the designer:
It's jarring at first but you get used to it.
I'm currently highlighting cells in Access 2007 using the default format > conditional highlighting option, however I'd like to be able to do this in VBA so I can got more detailed conditional formatting in.
Also, when I have a continuous form open there is always a black record at the bottom, that when typed into, creates a new record. Is there any way to delete this option?
Thanks a lot :)
Tim
You can set the AllowAdditions property for the form to No.
Extending the Functionality of Conditional Formatting in Access
For instance, I have a query which takes as a parameter the text property of a drop-down box [DDB1] of Form1.
How do I reference the property?
My stumbling around google has suggested that it should be something along the lines of
Forms![Form1]![DDB1].text
But I have been unable to find a definitive syntax for such references.
Any ideas?
Semi- OT - the Access2003 help, which contains links to a lot of Microsoft web pages, returns a lot of 404s when trying to load them. Is this just coincidence? Or end-of-lifing by stealth?'
To have a query reference a combo box on a form, use this syntax:
Forms!MyForm!MyComboBox
This will retrieve the selected value property of the combo box (the value of the first column, if it is a multi-column combo box).
If you want the selected value of a different column in the combo box, it is:
Forms!MyForm!MyComboBox.column(n)
Unlike most numeric indexes in VBA, n is zero based (the second column is 1).
To reference the text property, the combo box must have the focus.
The help file is apparently suffering from link rot. Here are some links in MSDN to use:
Access 2003 Programming Reference
http://msdn.microsoft.com/en-us/library/aa167788(office.11).aspx
Access 2003 Language Reference
http://msdn.microsoft.com/en-us/library/aa663079(office.11).aspx
You have in fact multiple ways to refer to a control with MS-Access. In addition to #Robert Harvey proposal, you can also write:
forms(myFormName).controls(myControlName)
Despite what #Robert says, you can access most properties of a control without setting the focus on it. One important exception is the ".text" property, which refer to the text appearing in the control, and where the focus must be set to the corresponding control.
Most of the time, the .text property is equal to the .value property, that can be accessed without setting focus on the control.
Thus, this property is useful only for controls of the combobox or listbox type, where the bound column (that gives the .value property) differs from the displayed column (giving the .text property).
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 :)