Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I make combo box works as ascending or descending on my form?

Status
Not open for further replies.

lebanoncedars

Programmer
Jul 17, 2002
43
CA
Hi there,
I have a continous form. I need a combo box to have options like ascending and descending to put (LastName) or Date or specific field in order.
Anyone knows How can I do that?
What are the steps should be done first?
Details please?

Thank you
Lebanoncedars
 
Do you mean you want the contenets of the Combo to be in order??
 
Hi Guys,
No.. No..
what I mean is;
I need to create a combo box on my form, and I wanna to have in it 2 options : ascending and descending.

My form contains so many fields, and one of those fields called I have a field called DATE:
Date(that would be costumer entered date)

So whenever I choose ascending option in the combo box or Descending, I want the Date to be IN ORDER from the top to the bottom or the opposite way.

I know I can do it straight and easier. Just right click date field and choose ascending or descending from that popup menu comes up.
But the reason to have a combo box there, so I can use that CODE later on for so many actions.

Thanks guys
Lebanoncedars
 
Hi again,
the other question is:
If I have a combo box with 3 options in it on my form.

Anyone knows How can I make a combo box turns specific field name on my form to a different name and at the same time change the field color to a different color?

my combo box contains these 4 options:
to be dispatched = red color
Dispatched = yellow color
Cleared = cyan color
Invoiced = dark blue color

And I have a field on my form called Status.
I need to turn the status field to the names and colors listed above in my combo box.
It means whenever I choose option (to be dispatched) in my combo box, the status field should change its name automatically
to : (to be dispatched) and its color changes to RED.

And if I choose the second option (Dispatched) in my combo box, the name should change from (to be dispathed) to (Dispatched)and its color changes to Yellow. and so on...

What are the steps should be done?
DETAILS PLEASE..Not much experience..

Thanks
Lebanoncedars
 
I don't know about the multi-colour text in the combo that would be a nice idea though.

Maybe you could fill the combo in code the use the listindex to change the forecolour of the text i personally have never tried this, but give it a try.(This is coming from my VB6 knowledge)

I think that you might only be able to change the forecolour of the complete list not per item.
 
Hello.

As far as I know, in order to do this, you will have to use multiple text boxes on the same form to imitate the list box.

So, say for example you have a table with a list of items that your shop sells. You may have the following table structure :

ItemID
Item Description
Unit Price
No In Stock

What we want to do here is change the back color of "No In Stock" to Red if there are none left (usually would be set when goes beyond re-order level)

1. Ok, so you create a block of 4 text boxes accross by 20 down.

ID Description Price Qty
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|
|----||---------------------------------||------||--|

2. Ok, so name each of these text boxes txtID1, txtDescr1, txtPrice1, txtQty1 (next row) txtID2, txtDescr2, ... etc ... txtQty20

So now add your own record selector buttons to the form. You must now write a function which gets any specific line from the table/query, and collects the data for each row.

In order to do this, you will need to create a datatype called "ItemRow" to capture the info once the function is called (as you cannot return more than 1 value in a function!).

The function definition would look like :

Public function getRowItem(Byval rowno as single, pagenumber as integer, redrawitem as boolean) as Integer

The function would receive the row number of the row to examine, the page number of the current page, and wether the function is to write each value into its respective text box on the form.

This function would return the item number of the item in question.

In the Form_Open, you reset the module variable Current_Page (to 1), then write the code that produces the first page of data, making sure that it checks each line for the item quantity to slip below its reorder level.

Change the record selector's code to reproduce each page.

OK, so if you aren't sure how to implement these changes then No, there isn't a way of changing the colour of each line in the combo box/list box. Microsoft didn't consider this when it released Access. I agree that it is a stupid idea for them not to consider this, but Access is a cheap system that was put in with other office products. In general Access is really only worth the hassle for small business solutions, not for complex GUI stuff that people think is always possible with Microsoft, It Isn't.

You may find on the web, other combo boxes that provide this kind of functionality. If I do, I will probably jump for joy, then reply back to this post.

Anyway, Hope this helps,
Mr Big.
Dont be small. be BIG
 
Hi guys,
this is the code I created . It works fine , Now what I'm missing is : to apply it ONLY to one record at the time , what I mean to a specific record.

COS I HAVE A CONTINUOUS FORM, and whats happening now tha column light up with the option i choose.

Can you guys be able to fix that. ONLY to specific record I need to apply it.

Private Sub Status_Click()

Status.ForeColor = vbBlack
text0.ForeColor = vbBlack
text0 = Status
Select Case Status
Case "To be Dispatched" 'Order to be dispatched
text0.BackColor = vbYellow
Case "Dispatched" 'Order Dispatched
text0.BackColor = vbGreen
Case "Cleared" 'Order cleared
text0.BackColor = vbCyan
Case "Invoiced" 'Order invoiced
text0.BackColor = vbBlue
Case Else
Status.ForeColor = vbWhite
text0.ForeColor = vbWhite
End Select

End Sub


Thanks
lebanoncedars
 
Hi.

I have tried to do this with continuous forms before. It doesn't work because if you set, for example, a controls color (textbox, combo box ...), it will set that control's color for all records in that continuous form. Access cannot distinguish between them.

However, you can have it as a single form, or use the method that I explained above.

I think that you are walking down a dead-end.

Regards,
Mr Big Dont be small. be BIG
 
Possibly put a "current record" statement somewhere? Just an idea. Also, what about making that form a datasheet view instead of continuous?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top