473,396 Members | 1,998 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.

Reference a Bound Combo Box In Report Through VBA

Hello,

I am using Access 2000.

I have a combo box that is bound to a query that lists the status' from the following table.

Status Table
---------------------------------
id name
---------------------------------
1 Identified
2 Development
3 Owner Review
4 Approver Review
5 Signed Off

the combo box shows the name and is bound by the id.

In the report I am creating I want to set a rectangle backcolor to a specific color depending on what status the certain record is.

So if status is 1, backcolor = yellow, etc

I can set the back color easily enough, but I cannot figure out how to check which status is in the combo for the life of me. The Text or Value property aren't there, etc. I am fairly knowledgable with Access and VBA but I cannot wrap my head around this. Any ideas?
Aug 19 '07 #1
7 1911
JConsulting
603 Expert 512MB
Hello,

I am using Access 2000.

I have a combo box that is bound to a query that lists the status' from the following table.

Status Table
---------------------------------
id name
---------------------------------
1 Identified
2 Development
3 Owner Review
4 Approver Review
5 Signed Off

the combo box shows the name and is bound by the id.

In the report I am creating I want to set a rectangle backcolor to a specific color depending on what status the certain record is.

So if status is 1, backcolor = yellow, etc

I can set the back color easily enough, but I cannot figure out how to check which status is in the combo for the life of me. The Text or Value property aren't there, etc. I am fairly knowledgable with Access and VBA but I cannot wrap my head around this. Any ideas?

I do apologise, but your question is kind of misleading. You're building a report...and we have to assume that it's data comes from the same source as some form? It appears as if you're storing the Numeric value from the combo box into a field in the record. And can we assume that this field is available to your report?
The rest is simple conditional formatting, and can be done by selecting the textbox that you want to change colors, and going to the menu, etc...

Can you clarify a little for us about what the source for the report is...and how it ties in with the value you select in the combo box?
Aug 19 '07 #2
Sorry about that I read it again and I see exactly where your coming from.

I have a report and the source is a query. In this query I have id, name, status. The status in the query is looking up values from another table. This is like I said before from the Status table. - Forget about this part, see next post for reason why.

Anyways. In the report, when it gets opened for viewing, I want a rectangle to be a certain color depending what the value of status is. When I drag the status field onto the report, it shows up as a combo box with the drop down arrow, but only while in design view. When viewing the report is just shows the value of the field which in this case is either Identified, Development, etc.

This is proving to be harder to explain than I though. I know what I'm trying to say but putting it work words is difficult.

Unfortunately you cannot do conditional formatting on a rectangle. But I may have an idea now that you mentioned that. I'll give that a shot while you guys try to figure out my horrible attempt at explaining a problem.

Hope this helped clarify a bit. If not.. I can give it another try. Lol. Thanks though!
Aug 19 '07 #3
My idea didn't work , but it wouldnt matter if it did because conditional formatting only allows 3 formats when I need upwards of 5.

Anyways what I was going to try to do is put the status field in behind the id and name and kind of turn it into the rectangle in a sense. Change its text color and background to be the same color with conditional formatting but that proved not to work. For what reason.. I'm not sure, but like I said the 3 formats would prove to be a problem.

Alright, well see how I can do at trying to explain this again.

Each id and name has a status associated with it. I want a rectangle behind the id and name that will change its color on report load depending on what the status associated with that id and name is.

-----------------------------
| 100-100-100 Name |
-----------------------------

It would look something like that but would be say... Yellow if status is identified, blue if status is development, etc.

I appologize. I lied in that last reply. The report is based off of a table which has id name and status. And status in that table is a lookup to the status table which included the id and name for each status which is:

1 Identified
2 Development
3 Owner Review
4 Approver Review
5 Signed Off

It's been a long day and my brain is some what mush...

Anyways, so what I was thinking of doing was going into VBA and using the On Open event. and in there somehow check to see what status is for each row that would be shown in the report and set teh rectangle backcolor according to that.

Private Sub Report_Open(Cancel As Integer)

' do the check in here.

End Sub

I might be thinking about that all wrong and there might be an easier way to do this. ANyways, thats my explaination hope this one helped out a bit more than the last two.
Aug 20 '07 #4
JConsulting
603 Expert 512MB
My idea didn't work , but it wouldnt matter if it did because conditional formatting only allows 3 formats when I need upwards of 5.

Anyways what I was going to try to do is put the status field in behind the id and name and kind of turn it into the rectangle in a sense. Change its text color and background to be the same color with conditional formatting but that proved not to work. For what reason.. I'm not sure, but like I said the 3 formats would prove to be a problem.

Alright, well see how I can do at trying to explain this again.

Each id and name has a status associated with it. I want a rectangle behind the id and name that will change its color on report load depending on what the status associated with that id and name is.

-----------------------------
| 100-100-100 Name |
-----------------------------

It would look something like that but would be say... Yellow if status is identified, blue if status is development, etc.

I appologize. I lied in that last reply. The report is based off of a table which has id name and status. And status in that table is a lookup to the status table which included the id and name for each status which is:

1 Identified
2 Development
3 Owner Review
4 Approver Review
5 Signed Off

It's been a long day and my brain is some what mush...

Anyways, so what I was thinking of doing was going into VBA and using the On Open event. and in there somehow check to see what status is for each row that would be shown in the report and set teh rectangle backcolor according to that.

Private Sub Report_Open(Cancel As Integer)

' do the check in here.

End Sub

I might be thinking about that all wrong and there might be an easier way to do this. ANyways, thats my explaination hope this one helped out a bit more than the last two.
I think I've grasped most of this now...so I'll hopefully point you in the right direction...I won't insult you by developing the solution as you seem to know what's what already.

Use the on_format event of your report.

create a Case statement based on the value of the field on the box.
Select Case me.SomeField
case x
me.box1.backcolor = vbyellow
case y
me.box1.backcolor = vbGreen
case z
me.box1.backcolor = vbRed
case else
me.box1.backcolor = vbWhite
end select

hopefully that will point you in the right direction AND I hope I'm not misreading again :)
J
Aug 20 '07 #5
That looks to be exactly what I need. And it worked perfectly! Thanks a ton for your help!

So how does that on format work?
Does it get called for every line that gets put into the report?
Aug 20 '07 #6
JConsulting
603 Expert 512MB
That looks to be exactly what I need. And it worked perfectly! Thanks a ton for your help!

So how does that on format work?
Does it get called for every line that gets put into the report?
Yes...along with a lot of other events that are record specific.

Here is a good place to start learning about the Order of events that occur with specific objects in your database.

http://office.microsoft.com/en-us/access/HP051867611033.aspx

J
Aug 21 '07 #7
Awesome! Thanks again!

I knew about all the rest but the reports and the order stuff is called was new to me! Appreciate it!
Aug 22 '07 #8

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

Similar topics

3
by: Cindi Simonson | last post by:
Hi, I have a form with a combo box containing 4 columns of data. The form also contains 3 print buttons where the goal is to open 3 different reports according to the value in one of the...
3
by: Adriano | last post by:
Hello, when I try to print something, either DataGrid or from Crystal Report viever the folowing error message appears and cancels printing: Object reference not set to an instance of an...
4
by: jon f kaminsky | last post by:
Hi- I've seen this problem discussed a jillion times but I cannot seem to implement any advice that makes it work. I am porting a large project from VB6 to .NET. The issue is using the combo box...
4
by: Evan | last post by:
I have a data bound combo box. The combo box displays several items (status code descriptions). After the combo box is bound, I want to set the combo box so that the "Draft" status is displayed by...
1
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1...
9
by: Vmusic | last post by:
Hi, I'm using MS Access 2002. I have a form with a combo box built from a query that returns one column, and that one column is the bound column. How do you use VBA to programmatically change...
14
by: mchlle | last post by:
How can I filter records of a subform that is part of a tab control? The filter works fine on the form when it is not part of the tab using this in the macro condition: !!="Today" I have a main...
5
by: consonanza | last post by:
I am working on a report filter form. It has 2 combo boxes (cmboSelectSubject and cmboSelectCategory) to select criteria. Selecting an entry in combo 1 restricts the options available in combo 2....
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.