Question Form - Combo Box

qiqinuinaifen128

Registered User.
Local time
Today, 11:34
Joined
Dec 21, 2008
Messages
29
Hi,

I have a two columns combo box. which is look like below

First Columns Second Column
1 Bank Transfer
2 Cash
3 Credit Card

after i selected any one of these three, the combo box only show the first column content. May i know how to set the combo box display only second columns after the selection is done.

Thank you in advance
Have a nice day ^^
 
In the Combo Box's Properties box go to the Data Tab. Click in the line labelled Row Source a button on the Right will appear with three dots in it. Click on this button and select the column that contain what is currently displaying as your second column and drag it one position to the left, of it's current position.
 
This will of course rearrange the way the columns currently display. but the column will be the display column once a selection is made.
 
Alternatively you could put an unbound text box on the form and set it's control source to;

Code:
=[Your_comboName].Column(2)

Remember the first column of a combo is always 0 (zero) so adjust the column number accordingly I have assumed that in addition to the two visible columns your combo also has a non visible bound column.
 
Thank you John. It's work!

I have another enquiries

First Columns Second Column
1 Bank Transfer
2 Cash
3 Credit Card


If i make a selection in my combo box, and i want to display the second column content in to a textbox. What is the code should i type?

Thank you so much.
 
Hi John, thank you for your generous help. It work ^^,

But i have another problem. Since i display a report into a textbox. But when i run the program. It prompted me a message

"The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data"

I know the textbox maximum can store only 256 char, how can i increase it, or is there any other way to solve this problem?
 
Try changing the field Data Type in the table design view to Memo. Memo fields can hold far more data.
 
Hi John,
Thank you. It's work
.
Today you solve alot of problem to me. Ha Ha ^^, i did learn a lot.

Another question ^^
if the i want to prompt message if the user didn't make any selection for a combo box. What is the code look like

I appreciate for your assist.
HAVE A NICE DAY!
 
Try the following in the OnLostFocus event of your Combo;

Code:
    If IsNull(Me.YourComboName) Then
        MsgBox "Please make a selection from the Combo Box", vbOKOnly, "Prompt For Selection"
        Me.YourComboName.SetFocus
    End If
 
Hi John,

Really thank for you help. I will try it now.

You are a good Access Guru^^. May i know how can be like you? Is there any free resource to study Access VBA.
 
Hi John,

I have another question need you to assist.
bolow is my code. Do you think it's ok for checking. or do you have better idea to improve it because the msgbox prompt continuously

Code:
   If IsNull(ClassType) Then
        MsgBox "Please make a selection from the Clsss Type", vbOKOnly, "Prompt For Selection"
        Me.ClassType.SetFocus
    End If
    
    If IsNull(Payment_Mode) Then
        MsgBox "Please make a selection from the Payment Method", vbOKOnly, "Prompt For Selection"
        Me.Payment_Mode.SetFocus
    End If
    
     If IsNull(PayFor) Then
        MsgBox "Please make a selection from the Pay For", vbOKOnly, "Prompt For Selection"
        Me.PayFor.SetFocus
    End If
 
I'd break it down into three separate checks and place each one in the OnLostFocus event for the control to which it relates.
 
Hi John,

I try your method, but it is not functioning.

I have a command button in my form. This button command is actually form a message and this message contains a infos which are from textbox and combo box, I had placed the code into the "OnLostFocus". However if i didn't made any selection for my combo box. The message is not shown.

Do you thing in this situation, it is better to place the code in the cmd button?

Thanks
 
You could put the specific code in the OnLost focus for each control that must have a selection and you could put your code modified as follows behind the CmdButton.

Code:
If IsNull(ClassType) Then
        MsgBox "Please make a selection from the Clsss Type", vbOKOnly, "Prompt For Selection"
        Me.ClassType.SetFocus
        [COLOR="Red"]Exit Sub[/COLOR]
    End If
    
    If IsNull(Payment_Mode) Then
        MsgBox "Please make a selection from the Payment Method", vbOKOnly, "Prompt For Selection"
        Me.Payment_Mode.SetFocus
        [COLOR="Red"]Exit Sub[/COLOR]
    End If
    
     If IsNull(PayFor) Then
        MsgBox "Please make a selection from the Pay For", vbOKOnly, "Prompt For Selection"
        Me.PayFor.SetFocus
        [COLOR="Red"]Exit Sub[/COLOR]
    End If

The Exit Sub statement I have inserted in each logical test will stop the Sub routine each time it finds a control with a null value, rather than it just skipping through the whole thing and giving you a number of MsgBox, that you have no chance to respond to.
 

Users who are viewing this thread

Back
Top Bottom