Changing background color of items in combo list

Chris;

here is a bigger copy of the DB in 2003 format. Only raw data was removed. I apologize for the incoinveinance I'm causing you.

chris
 
Last edited:
The values are not displayed because the text box is unbound.

Chris.
 
The version in post #21 is still corrupt.

Bigger is not necessarily better, problems are generally solved by reduction.

Attached is the version I’m now working on.

Chris.
 

Attachments

Chris;

Is the version you posted above the one you want me to use?

I've spent the morning getting my DB back to the error free way it was before I tried to create this control. Do you want me to upload it?

chris
 
Yes upload it and state which field the text box should be bound to.

Chris.
 
Chris;

here it is. I put a label on the form called frmProductionNumbers where I was going to put the time control. The bound field is TimeID on tblProductionNumbers

chris
 

Attachments

Last edited:
Chris;

Please forgive my knuckleheadery. I kept telling myself to convert to 2003 but when the time came to do that the other part of me kept that info to itself. I've posted it above.
 
That Form is still corrupt in Access 2003, can’t be saved.

Here’s another upload that does most of what you want.
There’s a small problem in that on selecting a time more than once it requires two clicks of the List box.
Don’t know why.

Chris.
 

Attachments

That Form is still corrupt in Access 2003, can’t be saved.

Here’s another upload that does most of what you want.
There’s a small problem in that on selecting a time more than once it requires two clicks of the List box.
Don’t know why.

Chris.


Do you think the corruption issue is because I created the DB in Access 2010 and then down saved to 2003? I will take a look at this tomorrow morning. The confusion I ran into last time was that the control was saved onto a form, of course, but from there I didn't know how to get the control pieces from that form into my form, as well as how to bring the code into my project. Is there some automated way to bring the control and code into my project or must it be picked apart and placed into my project?

chris
 
I guess the corruption could be due to the conversion.

As for the other thing just copy and paste them over manually.

Chris.
 
Still cannot get it to work. Neither one. Even tried to mix and match.
I've left off using the first solution, as it seems to have less issues.
Plugging the code it piece by piece compiles, but when I open the form with the control on it, I get a Runtime error 2950, Reserved error. several other errors after that.

How can something that seems to be so easy, not work? At this point as frustrated as I am with this it's basically a rhetorical question.
 
Does the upload I posted in post #29 work in A2010?

If so then the problem is in your Form which to me is corrupt.

Sorry but that’s all I can do.

Chris.
 
it "works" in 2010 but has the weirdness you talked about. Having to click/select a time by clicking several times on it. Also doesn't present the different color in the box after selection. John Big Booty's upload works the best. Just not sure why plugging the code in a piece at a time gives me errors. I'll try this again, after all it's Monday, maybe it'll be nice to me today.....;)
 
it "works" in 2010 but has the weirdness you talked about. Having to click/select a time by clicking several times on it. Also doesn't present the different color in the box after selection. John Big Booty's upload works the best. Just not sure why plugging the code in a piece at a time gives me errors. I'll try this again, after all it's Monday, maybe it'll be nice to me today.....;)
The DB I posted is still ChrisO's I only tweaked the SQL in it.
 
thanks guys;

I'm thinking the only way to do this, given the errors, is a step by step process.

Here is what I did:
1.) I copied/pasted in the four different parts of the control, the text box to show time selected, the down arrow button, the box for AM times and the box for PM times.
2.) I then arraigned the boxes in the same design as provided.
3.) I started to cut/paste the code from sample DB to my DB. Pressed Alt/F11 to bring up code window. I had previously imported the form into my project to do the cutting/pasting. The form is closed, but I can see it listed under MS Access Class Objects in the MS VBA window.
4.) the first code I cut/paste was the form open code in the open form event.
5.) the next code cut/paste was for down arrow.
6.) tried to compile, got error of "Sub or function not defined".
7.) I then cut/paste in the code for "SetVisibility" above the code for "cmdShowLists" as in the sample DB to define it. It then compiled.
8.) At this point I ran the form, even though the code for the AM/PM boxes weren't plugged in. Wanted to see what happened. Got error 2950 Reserved Error. When I debugged, the line highlighted in yellow was under Setvisibility and was the first line" Me.cmdShowLists.SetFocus" I commented out that line and then compiled it.
9.) I ran the form again and it didn't give an error. The control on the form had the word "#error" in the text box that was supposed to show the time, probably because it isn't bound to anything yet. I saw that the list boxes were compacted. When I clicked on the down arrow command button, the list boxes both expanded to show AM/PM times to be selected. I clicked on them and they didn't work because I haven't entered in the code behind those list boxes yet.
10.) I entered in the code for both AM/PM times list boxes and compiled.
11.) I changed the form from design view to form view. No errors. I selected the command button and the list boxes came down showing both AM/PM times. So far so good.
12.) I then tried to select either an AM or a PM time and the error I got was Run-Time error 2448 You can't assign a value to this object. If I select an AM time, I get an error that highlights in yellow ".Value = Me.1stDayshift" If I select a PM time, the error is the same only it references the same line in the Nightshift code.

In the error listed in #8 above, my command button is named cmdShowLists. My AM list box is named lstDayShift and my PM list box is named lstNightShift. I thought the numeral of "1" had been used but I see that it is really a lower case "L" "l" and "1" look almost the same but it appears an "L" was used, not a "1".

If I go back and uncomment line #8 as above, I get the same error listed in #8 when I run the form.

Hopefully this helps.....

chris
 
There have been a few changes, version 3 is attached.

First test it in Access 2010 and if it works import all of the code to your old Form.

Chris.
 

Attachments

There have been a few changes, version 3 is attached.

First test it in Access 2010 and if it works import all of the code to your old Form.

Chris.


Chris;

I tested the form. Opened it up in Access 2010. The form opens without error, however, it opens to a random time being displayed in the text box. I cannot select another time from the list boxes. The color in the box will change from yellow to black depending on either AM or PM time, however the time never changes. Whatever time was displayed when going from form view to design view is the time that will be displayed when going from design view back to form view.

So for instance, I open the form and the time of 12:30PM is displayed. The time is yellow, as it should be. If I try to select, say, 6:30 PM, the time of 12:30PM stays in the text box but the color is changed to black, which is the color that the 6:30PM time should be. If I switch to design view then back to form view, the new time displayed is now 6:30PM, and the color is black, as it should be.

I thought I'd do this step by step and report back what happens.

chris
 
In design view, check if you have [Event Procedure] in the OnClick property of both List Boxes.
You may have lost one or both when converting to Access 2010.

Maybe someone else can verify this behaviour.

Chris.
 
In design view, check if you have [Event Procedure] in the OnClick property of both List Boxes.
You may have lost one or both when converting to Access 2010.

Maybe someone else can verify this behaviour.

Chris.

I've plugged in all the pieces into my project and it compiles. When I change from design to form view, I get an RT error "Invalid use of null" When I debug the line in yellow is Private Sub Form_Current() SetShiftColours Me!TimeID.
 

Users who are viewing this thread

Back
Top Bottom