By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

Combo box activate a listbox

P: 36
Hi Gente,

I need to Know how I can activate a list box value with combo box after update function. example I have a combo box if i chosse any in list from combo box then activate a list box "like on_click" selecting the last autonumber ID in this list box.

¿How? Masters!

Thanks for any Ans.... Gracias!!!
Aug 6 '07 #1
Share this Question
Share on Google+
16 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
I'm not sure from your question exactly what you are doing but have a look at this tutorial and see if it helps.
Aug 6 '07 #2

P: 36
I'm not sure from your question exactly what you are doing but have a look at this tutorial and see if it helps.
Thanks for your Answer but its not a Cascading Combo box Im not sure.

OK, If I select a value in combo box then go to my list box and select the last autonumber record. Like activate the function for my list box and Automatic chose the last record in list box.
Aug 7 '07 #3

Scott Price
Expert 100+
P: 1,384
Your questions aren't clear enough at this point to be able to help out.

If you would be more comfortable in spanish, I can try to help out with your question, or if I can't answer it I can translate so one of the experts CAN answer it.

What is the name of your combo box, what is the name of the list box, and what is the data represented in each?

Regards,
Scott
Aug 7 '07 #4

P: 36
Your questions aren't clear enough at this point to be able to help out.

If you would be more comfortable in spanish, I can try to help out with your question, or if I can't answer it I can translate so one of the experts CAN answer it.

What is the name of your combo box, what is the name of the list box, and what is the data represented in each?

Regards,
Scott
Hi Scott

My Combo box is cbobranch and my list box is lstRates I need to select any branch in my cbobranch then my list box lstRate select automatic the recently Rate in table. The user only click any value in cbobranch and the lstRate choose the the ultimate rate entry.

Hola Scott
Mi combo box es cbobranch y mi list box es ldtRates cuando seleccione una sucursal en mi combo box automaticamente se activa el list box lstRates. El usuario no necesita hacer click en el lstRates.


Sorry for my english.

Thanks for your time.
Aug 7 '07 #5

Scott Price
Expert 100+
P: 1,384
De nada por cualquier ayuda que puedo ofrecerle...

¿Qué es la estructura de su forma? ¿Es basada en un 'query', o en un 'table'?
¿En su combobox, es cada branch associada con solo un valor en su listbox?
¿Qué es la estructura de su combobox y listbox? Por ejemplo, para hacer funcionar lo que está tratando de hacer, tiene que tener 2 columnas en cada control, la primera columna debe ser el numero de identificación. La primera columna puede tener una anchura de 0" para que no pueda verla.

A mi parecer, no tiene que usar un 'listbox' por lo que está tratando de hacer, un 'textbox' sería suficiente.

Mis pensamientos en este momento, sin saber las respuestas de mis preguntas arriba, es que tiene que basar su forma en un query que jala los valores necisarios. En su query, en el campo 'criteria' debajo de su campo Rates, entre este: Forms![NombreDeSuForma].cboBranch

Su combo box no tiene que ser 'bound' (pegada) a ningun campo en su query, pero el textbox o listbox si, tiene que ser pegada al campo Rates de su query. Suficiente para su combo box tener en el 'Row Source', algo semejante a:
Expand|Select|Wrap|Line Numbers
  1. Select BranchID, Branch From tblBranch
Despues, entre este codigo en el evento "AfterUpdate" de su cboBranch: (en ingles :-)

Expand|Select|Wrap|Line Numbers
  1. Me.Requery
Y, su ingles está bien...

Ojalá que este sea de ayuda...

Regards,
Scott
Aug 7 '07 #6

Scott Price
Expert 100+
P: 1,384
I will happily translate this post into English to avoid running afoul of the general posting guidelines, as well as to be helpful to anyone else who is browsing this forum!

The general reply I gave is:

What is the structure of your form? Is it based on a query or a table? In your combo box, is each branch associated with only one value in your listbox? What is the structure of your combobox and listbox? For example, to make what you are trying to do work, you need to have two columns in each control, the first column should be the ID number field, and only needs to have a width of 0", so you don't have to see the numerical value in it.

I don't think you need to use a listbox for what you are trying to do, a textbox should be enough.

My thoughts at this moment, without knowing the answers to my questions above, is that you need to base your form on a query that pulls the needed values. In your query, in the criteria field below your Rates field, enter this: Forms![YourFormName].cboBranch...

Your combobox can be unbound, but your text/listbox needs to be bound to the Rates field of your query. It should be enough for your combo box to have it's Row Source setting something like this:
Expand|Select|Wrap|Line Numbers
  1. Select BranchID, Branch From tblBranch
Then, enter this code in the AfterUpdate event of your cboBranch:

Expand|Select|Wrap|Line Numbers
  1. Me.Requery
Scott
Aug 7 '07 #7

Scott Price
Expert 100+
P: 1,384
Disculpe,
Expand|Select|Wrap|Line Numbers
  1. Forms![NombreDeSuForma].cboBranch
tiene que estar en el campo criteria debajo de BranchID en su query.

Excuse me,
Expand|Select|Wrap|Line Numbers
  1. Forms![YourFormName].cboBranch
needs to go in the criteria field under your BranchID field in your query.


Regards,
Scott
Aug 7 '07 #8

P: 36
Disculpe,
Expand|Select|Wrap|Line Numbers
  1. Forms![NombreDeSuForma].cboBranch
tiene que estar en el campo criteria debajo de BranchID en su query.

Excuse me,
Expand|Select|Wrap|Line Numbers
  1. Forms![YourFormName].cboBranch
needs to go in the criteria field under your BranchID field in your query.


Regards,
Scott
Hi Scott, Thanks for your time, my answers is under line for your Q?

Q. What is the structure of your form?
- Is a single form
Q. Is it based on a query or a table?
- Is based on a query, include tblbranch, tblEmployees, tblRates & the many table tblCharges. The branch & Employee tables are related with tblCharges. but the tblRate is not related.
Q. In your combo box, is each branch associated with only one value in your listbox?
- The combo box it obtains the info. for tblbranch. The combo box have branchID & list the name of branches 2 columns. The branchID is related with branchID field in the many tblCharges. if I choose the first name branch then the branchID resgistered in the many tblCharges.
- My list box have 7 columns RateID its included in the 7 but the user no see this field. Only see the numbers of fields rates ex. 10, 0.08 etc..and the field date for any change in the rate.

I put the criteria in a query - Forms![YourFormName].cboBranch under branchID
and Me.Requery afterupdt in cbobranch. But not function. My list box can't activate. My combo box after updt can't select in the list box the last rate that user entry.

Any other info. for your great help as need ask me...

Thanks Again
Aug 7 '07 #9

Scott Price
Expert 100+
P: 1,384
Hi Scott, Thanks for your time, my answers is under line for your Q?

Q. What is the structure of your form?
- Is a single form
Q. Is it based on a query or a table?
- Is based on a query, include tblbranch, tblEmployees, tblRates & the many table tblCharges. The branch & Employee tables are related with tblCharges. but the tblRate is not related.
Q. In your combo box, is each branch associated with only one value in your listbox?
- The combo box it obtains the info. for tblbranch. The combo box have branchID & list the name of branches 2 columns. The branchID is related with branchID field in the many tblCharges. if I choose the first name branch then the branchID resgistered in the many tblCharges.
- My list box have 7 columns RateID its included in the 7 but the user no see this field. Only see the numbers of fields rates ex. 10, 0.08 etc..and the field date for any change in the rate.

I put the criteria in a query - Forms![YourFormName].cboBranch under branchID
and Me.Requery afterupdt in cbobranch. But not function. My list box can't activate. My combo box after updt can't select in the list box the last rate that user entry.

Any other info. for your great help as need ask me...

Thanks Again
1. Does each branch have a particular rate associated?

2. Or are you trying to simply have a rate display in the list box according to the latest dated rate?

If #1, then in order to have your cboBranch affect your list box Rates, you will have to relate the two tables in your query in some way.

Please post the sql code behind this query... (go into query design view, right click on the top of the query window, choose sql view, and copy/paste to a reply here.)

Where does your listbox get its data from? Is it from a separate query, or is it pulling from the same query as your main form?

If #2, I'll need to know more about your listbox, such as it's row source property, etc...

You're doing quite well in English so we continue without the Spanish for the moment... If needed we can switch :-)

Regards,
Scott
Aug 8 '07 #10

P: 36
1. Does each branch have a particular rate associated?

2. Or are you trying to simply have a rate display in the list box according to the latest dated rate?

If #1, then in order to have your cboBranch affect your list box Rates, you will have to relate the two tables in your query in some way.

Please post the sql code behind this query... (go into query design view, right click on the top of the query window, choose sql view, and copy/paste to a reply here.)

Where does your listbox get its data from? Is it from a separate query, or is it pulling from the same query as your main form?

If #2, I'll need to know more about your listbox, such as it's row source property, etc...

You're doing quite well in English so we continue without the Spanish for the moment... If needed we can switch :-)

Regards,
Scott
Yea number 2, the first field in the list box like "column" is DateChangeRt. Its better for the user to know what is the correct rate for any branch to choose.

Only display rates but the user select the correct for any branch right now. I desire to avoid that the user select rate is not exiting any change for any branch.

My cbobranch is:

SELECT tblBranch.BranchID, tblBranch.BranchName FROM tblBranch ORDER BY tblBranch.BranchName;

My lstRate is:

SELECT tblRate.RateID, tblRate.DateChangeRt, tblRate.NofixedRt, tblRate.QuantityRt, tblRate.SchgRqtRt, tblRate.SchgSpeRqtRt, tblRate.SchgSaRt FROM tblRate;

thanks scott
Aug 8 '07 #11

Scott Price
Expert 100+
P: 1,384
You didn't specifiy, but assuming that your list box is based on this query in it's Row Source field

SELECT tblRate.RateID, tblRate.DateChangeRt, tblRate.NofixedRt, tblRate.QuantityRt, tblRate.SchgRqtRt, tblRate.SchgSpeRqtRt, tblRate.SchgSaRt FROM tblRate;
To show ONLY the latest changed record, you can change it to this:

SELECT tblRate.RateID, tblRate.DateChangeRt, tblRate.NofixedRt, tblRate.QuantityRt, tblRate.SchgRqtRt, tblRate.SchgSpeRqtRt, tblRate.SchgSaRt FROM tblRate WHERE tblRate.DateChangeRt = DMax ("[DateChangeRt]", "tblRate");

This will return only one row in your list box, the row with the latest date...

Not sure if this is really what you are looking for, but it is actually the most efficient way of displaying the data you are asking for (as I understand your request).

Regards,
Scott
Aug 8 '07 #12

P: 36
You didn't specifiy, but assuming that your list box is based on this query in it's Row Source field



To show ONLY the latest changed record, you can change it to this:

SELECT tblRate.RateID, tblRate.DateChangeRt, tblRate.NofixedRt, tblRate.QuantityRt, tblRate.SchgRqtRt, tblRate.SchgSpeRqtRt, tblRate.SchgSaRt FROM tblRate WHERE tblRate.DateChangeRt = DMax ("[DateChangeRt]", "tblRate");

This will return only one row in your list box, the row with the latest date...

Not sure if this is really what you are looking for, but it is actually the most efficient way of displaying the data you are asking for (as I understand your request).

Regards,
Scott
Hi Scott,

The instruction code its work in the list box but for I need no.

I need that the "listbox" activate for "Default" the last one "Record" but that the user have option to choose some previous. When the "Combo box" be selected be activated the "list box" like "on click" function. The "list box" is not still selected. The "list box" it should activate after update in combo box.

Necesito que el "list box" active su función en el "record" más reciente pero que el usuario no tenga que hacerlo "On Click". Este debe activarse luego de seleccionar el "Combo box".

Thanks for your time....
Aug 8 '07 #13

Scott Price
Expert 100+
P: 1,384
Hi Scott,

The instruction code its work in the list box but for I need no.

I need that the "listbox" activate for "Default" the last one "Record" but that the user have option to choose some previous. When the "Combo box" be selected be activated the "list box" like "on click" function. The "list box" is not still selected. The "list box" it should activate after update in combo box.

Necesito que el "list box" active su función en el "record" más reciente pero que el usuario no tenga que hacerlo "On Click". Este debe activarse luego de seleccionar el "Combo box".

Thanks for your time....

In the AfterUpdate event of your combo box, set the focus to your list box with this line of code:
Expand|Select|Wrap|Line Numbers
  1. Me![YourListBoxName].SetFocus
In the GotFocus event of your listbox you will need to do a recordset/bookmark. You can try writing the code yourself, looking in MS Access help file for the syntax. I've got a snippet of code I'm working on at the moment, but won't post it yet because it's not behaving correctly in my test db... I only mention this for reference purposes, and so you can get a jumpstart on understanding the concept of what we're trying to do.

[Added Idea] You can, as another idea, change the RowSource of the list box to this:
Expand|Select|Wrap|Line Numbers
  1. SELECT tblRate.RateID, tblRate.DateChangeRt, tblRate.NofixedRt, tblRate.QuantityRt, tblRate.SchgRqtRt, tblRate.SchgSpeRqtRt, tblRate.SchgSaRt FROM tblRate; ORDER BY tblDate.DateChangeRt DESC; 
This will place the latest dated record as the first record listed in your listbox.

Back Soon!
Regards,
Scott
Aug 8 '07 #14

Scott Price
Expert 100+
P: 1,384
If instead of ordering the list box by descending date, as in my previous post have a look at this thread, where I got help from JKing to debug the select record in listbox function...

http://www.thescripts.com/forum/thread689835.html

Regards,
Scott

p.s. please post back to let us know if you've got it working!
Aug 8 '07 #15

P: 36
If instead of ordering the list box by descending date, as in my previous post have a look at this thread, where I got help from JKing to debug the select record in listbox function...

http://www.thescripts.com/forum/thread689835.html

Regards,
Scott

p.s. please post back to let us know if you've got it working!
Hi Scott

Ok, the setfocus vb work like this, afterupdate in combo box the list box get focus correct but no activate the list box function like On_Clik. OK I try to insert an image in this post for better explain and view the example but I don't know how.

it will continue playing with the code....
Aug 9 '07 #16

Scott Price
Expert 100+
P: 1,384
Hi Scott

Ok, the setfocus vb work like this, afterupdate in combo box the list box get focus correct but no activate the list box function like On_Clik. OK I try to insert an image in this post for better explain and view the example but I don't know how.

it will continue playing with the code....
Make sure to go to the end of the thread in order to get the correct code!

If you continue having problems, post the code you are using, including any changes you have made to it...

Regards,
Scott
Aug 9 '07 #17

Post your reply

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