Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 17th, 2005, 08:24 PM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default reference specific instances of a subform

Does anyone know if it is possible to reference a specific instance (ie. record) of a subform and set properties relating just to that instance?

eg. I have a subform which I wish to display in "continuous forms" so that several records are shown at a time. If, for arguments sake, there was a textbox on the subform called 'price' and I wanted to change the backcolor to red if price was <10, or green if >9 could I do it by referencing the relevant row?

If I examine 'price' on the current record and set the backcolor it affects every row on the subform. I can get round it by setting the subform to 'single form' but this means having to navigate to each record in turn, which is not what I want.

Any ideas??

nb. my actual application is much more complicated thqn the 'price' example, but I thought I'd keep it simple :)

 
Old January 18th, 2005, 01:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Have you tried opening the subform in design view, selecting the relevant control, then selecting from the Formatting Menu: Format > Conditional Formatting and playing with the "Field Value is" condition. May give you the results you're looking for.

HTH,

Bob

 
Old January 18th, 2005, 07:23 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the reply Bob. That certainly works well for simple cases and I'm sure I'll take advantage of that some day. What I've actually got is a situation where I want to change the control source for a field depending on the value of another field.

eg. when displaying the components of a 'toy car' product I'd have a 'Product' table & 'Component' table. A 'toy car' might be made up of 1 electric motor and 4 wheels amongst other things. The electric motor might only ever have 1 [u]fixed</u> description, which would be stored on the 'Component' table. The wheels, however, might have several [u]variable</u> descriptions, depending on the product. ie. rear right wheel, rear left wheel etc.

My subform is based on a 'Product/Component' table. Here I was intending to store the variable descriptions. When I display the subform I only want to pick up the relevant description field. So if the component was of a 'fixed' type the description would be mapped onto the 'Component' table and be non-editable. If it was 'variable' the description would be mapped onto the 'Product/Component' table and be editable. Each row would be examined as to whether the component was Fixed or Variable, and then the relevant table.column would be assigned as the field's control source. An alternative might be to have 2 fields for the descriptions, making 1 of them 'visible' & the other not 'visible'.

Using the subform's 'current' event I'm able to do either of the above but the effect applies on [u]all</u> rows not just individual ones. (I want to show all rows ie. continuous form, not 1 at a time.)

Hope this makes sense !! What I'm actually working on is to do with high volume printing, concerning inserts, stock codes etc, but I thought the toy car analogy would be easier to illustrate the point.

I'd guess that I'm trying something that can't be done in Access in which case I'll have to redesign the data, unless someone knows a neat way round ;).

Paul






Similar Threads
Thread Thread Starter Forum Replies Last Post
Search specific data from specific columns yogeshyl SQL Language 1 January 16th, 2008 11:12 AM
Copy specific data in specific cells of sheet2 yogeshyl Excel VBA 1 May 14th, 2007 07:40 AM
Going to a specific record in a separate subform discorhino Access VBA 2 August 7th, 2006 12:35 AM
wrong reference of a subform mjuliao Access 5 November 20th, 2005 02:27 PM
form/subform reference tmc Access 1 August 7th, 2004 04:16 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.