473,396 Members | 1,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Highlighting Datasheet Rows in Subform

Breezwell
I have done some searching on this one and I have yet to find any information that sheds light on what I am trying to do. At lease from what I can understand.

Basically, I have a main form which has a single subform. The subform presents a datasheet view of a a query. The query results present information in such a manner that a single column, call it GroupCode, can have numerous duplicate entries. This is actually desired as a normalized database is not what I need. So, I could have entries in the GroupCode column like the following:

GroupCode
*************
96445
96445
96445
87343
87343
87787
87787


What I would like to do is highlight each set of rows with the same GroupCode in a similar background color. In other words, I would like all records with GroupCode 96445 to be highlighted a certain color. I would like to skip highlighting on 87343 GroupCodes, then apply higlighting again to 87787 GroupCodes. Basically, alternate highlighting such as is possible in Excel.

Is this even possible in Access? If so, are ADO Recordsets where I should be looking?

Thanks for any guidance on this issue.
Sep 24 '08 #1
5 9639
Stewart Ross
2,545 Expert Mod 2GB
Hi. It is not possible to highlight alternate rows. It is possible to highlight duplicates using conditional formatting, but it would be very slow in operation. Reason for the slowness is that you would need to include a count of the number of rows matching your group code number, using the DCount function to do so (any other approach would prevent your table data from being updatable), and DCount coupled with conditional formatting would slow your form down considerably.

To highlight the rows concerned in a different background colour you would place a rectangle on the form as a background for your controls, and set its background colour property using conditional formatting whenever the control containing your DCount had a value > 1. The control with the count does not have to be visible; it can be hidden so as not to interfere with the existing content of your rows.

There is a short HowTo article by our highly-experienced site administrator NeoPa which provides a much fuller background on why the alternating formatting is not possible. The article is called Why Values in Unbound Form Controls Don't Persist - and it applies just as much to the formatting of continuous form backgrounds as to unbound controls.

I attach an example of the use of conditional formatting in one of my forms (a student payment system, with red background used to indicate withdrawn students).

-Stewart
Attached Images
File Type: jpg ScreenHunter_67.jpg (15.1 KB, 802 views)
Sep 24 '08 #2
Stewart,

Thank you for the detailed reply.

The process of highlighting the records according to the GroupCode really is just to provide some 'visual breakout' of the records in datasheet view for quick inspection. The color method is not mandatory, but I figured it would be the easiest.

Do you happen to know if there is simply a way to add a blank record between each group of records with the same GroupCode in the datasheet view only and not in my actual table?

I am thinking I could export my data to Excel, run a Subtotal against the data, remove the data in the Totals row, then export the file back into Access, utilizing the Totals row as a sort of divider in the Access datasheet view. This seems like an ugly hack that will create an ugly master table,

Thanks
Sep 24 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Breezwell. In databases there is no way that you can add blank rows in the way you describe; a database table or query has no inherent concept of record position, so any attempt to present data that relies on implicit row sequencing - record, blank, record, blank for example - cannot be achieved using normal database techniques. Excel is strongly influencing you here!

I should mention that it is possible to do things in Access reports - hiding duplicate values, programming detail sections to alternate shading - which cannot be done in tables, queries or forms. However, alternate row shading in report detail sections is similar in approach to the conditional formatting of forms, except that it is the detail section itself which is shaded alternately instead of a background box overlaid onto the data, and it is done from VBA code within the report.

-Stewart
Sep 24 '08 #4
Megalog
378 Expert 256MB
Which version of Access are you using? Alternate row shading is a built-in feature now in Access 2007. I use it along with groupings in reports all the time.
Sep 24 '08 #5
Stewart,

I really appreciate the insight. You replies kept me from going mad trying to figure out why I could not figure this out.

I am currently stuck with Access 2002. There is no way for me to upgrade on my work machine unfortunately. We are just now rolling out Access 2003.

I did manage to accomplish, albeit hideously, what I needed to do. Just for laughs, here is what I ended up doing. I will put these in steps since it seems so comical to me.

1. I exported my table into Excel.
2. I did a subtotal of all records and specified a summary for each change in GroupCode using the Count Num function on the GroupCode column. This put a 0 in the summary section for all GroupCodes for thier given grouping, providing me with the breakout visual I needed.
3. I then put some dummy text 'foo' in a blank cell (D3).
4. I then did an Auto Filter and selected all the cells with the 0.
5. I then put the following code in the first cell with the deleted 0: =IF($D$3 = "Foo", $D6 & " //////// End //////////")
6. I copied this if statement to all cells that had a 0 and this updated each grouping.
6. I then exported the Excel spreadsheet back into Access with the correct table name.

So, whenever I now do a search based on the queries I have set up, all GroupCodes are listed and at the end of every group there is an entry such as:

98875
98875
98875
98875 //////////////////// End //////////////////////////
8776
8776
8776 /////////////////// End ///////////////////////////

in my datasheet view.


Like I said, it us ugly and crude, but it does what my users need. I am almost embarrased to show how I did this, but my users think it is amazing that they can look at so much data and be able eyeball the groupings. I guess that is what really matters.

Thanks again for your help and I hope to contribute some 'professional' level stuff one day myself. :)
Sep 24 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: codemonkey | last post by:
TIA! I would like to know if there is a way to dynamically change the colors of Subform items? I have already set in place Conditional Formatting so each row has an alernating color scheme, but...
3
by: Mark | last post by:
Hi there, I have a subform, set as a continuous form. When a user selects a particular record in that subform, how can I make that particular record stand out (color or font change, size, etc) from...
5
by: kotowskil | last post by:
A report has a subform. The subform is set to datasheet view and its RecordSource is a select query that includes a memo field from the source table. The memo field's Can Grow property is Yes,...
3
by: matthewemiclea | last post by:
So I think this may be a stretch, but I have a subform that is displayed on a main form. The subform is based on a query that brings records from a table(It does not bring all fields, but the main...
1
by: s_wadhwa | last post by:
Hi, I have a main form "frmBldgFloor" and SubForm within the main form "fsubBldgFloor". In the SubForm the values in the text fields are being populated from a recordsource. I have these...
1
by: sherbert1967 | last post by:
How do I determine (from main form) what rows have been selected within a (datasheet style) subform. As I need to transfer these rows to another table. Can this be achieved via code? Please...
3
by: Danny J. Lesandrini | last post by:
-- previously posted on newsgroup :: <microsoft.public.access-- Has anyone else noticed this behavior? Focus jumping from current cell to upper left in embedded datasheet. If not, would you be...
8
by: Lynx101 | last post by:
Hi, hope anyone can help with this query. Background: Subform datasheet link to a form to store updates on projects. Query: I have a datasheet where one of the field is a memo field. When...
7
by: CCHDGeek | last post by:
I have a subform that is searched according to a field value on the main form. The subform has mutiple pages and each page has a subform based off a query. Today when I logged into the main form,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.