[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Set value of 2 column combobox

Posted on 2009-02-11
10
Medium Priority
?
2,350 Views
Last Modified: 2013-11-28
Good Day Experts!,

I just have a simple question.  I have a 2 column combobox tied to a query rowsource, column withs are 0 and 1 so bound column is basically hidden.  I know you can set a value if its a one column listbox just by using me.comboname.value = "whatever", but i surmise in doing so, only sets a value to the 1st bound column.  Now since the only visible column is the 2nd column, is there any way to set a value to it?  Thanks!
0
Comment
Question by:jad0083
  • 5
  • 4
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 23616448
yes you can..

what is the rowsource of your combo?
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 23616494


    With Me.Combo0
        For i = 0 To .ListCount - 1
       
            If .Column(1, i) = "SomeVaue" Then
            .Value = .Column(0, i)
           
            End If
        Next
    End With
0
 
LVL 33

Expert Comment

by:jppinto
ID: 23616495
On your Combo Bound Column put 2 instead of 1. This will still show only the first column but will make the Combo.value bound to the 2nd column.

jppinto
0
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 

Author Comment

by:jad0083
ID: 23617116
This is the rowsource I'm using:
get_type = "SELECT ID, F_Type FROM Fraud_Types WHERE Active = -1 ORDER BY 1 ASC;"

comment # 2 doesn't work for some reason, and I can't move the bound column to the 2nd column since i already built the form around using the value of the 1st column...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 23617420
did you try the codes i posted?
0
 

Author Comment

by:jad0083
ID: 23617508
@capricorn1

Yeah, I tried it and the combobox still doesn't show any value you set to it...
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 23617531
post the codes that you used..
0
 

Author Comment

by:jad0083
ID: 23617800
Attached is the code I used:


Dim get_type As String, get_group As String, get_reasons As String, get_submitted As String
 
get_type = "SELECT ID, F_Type FROM Fraud_Types WHERE Active = -1 ORDER BY 1 ASC;"
get_group = "SELECT ID, Group_Name FROM F_Group WHERE Active = -1 ORDER BY 1 ASC;"
get_reasons = "SELECT ID, Reasons FROM Denial_Reasons WHERE Active = -1 ORDER BY 1 ASC;"
get_submitted = "SELECT Main_Records.ID, Fraud_Types.F_Type, F_Group.Group_Name, Main_Records.Account_Number, " & _
                "Main_Records.Fraud_Amount, Main_Records.Denial_Reason_ID, FORMAT(Main_Records.Denial_Date, 'hh:mm:ss am/pm'), " & _
                "Main_Records.Status FROM ((Main_Records LEFT JOIN Fraud_Types ON Main_Records.Fraud_Type_ID = " & _
                "Fraud_Types.ID) LEFT JOIN F_Group ON Main_Records.Group_ID = F_Group.ID) LEFT JOIN " & _
                "Denial_Reasons ON Main_Records.Denial_Reason_ID = Denial_Reasons.ID WHERE Main_Records.Analyst = " & _
                "'" & fOSUserName() & "' AND FORMAT(Denial_Date, 'MM/DD/YYYY') = FORMAT(NOW(), 'MM/DD/YYYY') " & _
                "ORDER BY Main_Records.Denial_Date DESC;"
 
 
Me.Type_Combo.RowSource = get_type
Me.Group_Combo.RowSource = get_group
 
Me.Denial_list.RowSource = get_reasons
Me.Stats_List.RowSource = get_submitted
Me.Acct_txt.Value = ""
Me.Amount_txt.Value = ""
Me.Denial_list = Null
 
'Me.Type_Combo.Value = "[Select Type]"
'Me.Group_Combo.Value = "[Select Group]"
 
With Me.Type_Combo
        For i = 0 To .ListCount - 1
       
            If .Column(1, i) = "[Select Type]" Then
            .Value = .Column(0, i)
           
            End If
        Next
    End With
 
With Me.Group_Combo
        For i = 0 To .ListCount - 1
       
            If .Column(1, i) = "[Select Group]" Then
            .Value = .Column(0, i)
           
            End If
        Next
    End With

Open in new window

0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 2000 total points
ID: 23617886
you have to add that value to the row source of your combo

ELECT Fraud_Types.ID, Fraud_Types.F_Type FROM Fraud_Types Where Fraud_Types.Active=-1 UNION SELECT Null, '[Select Type]'  FROM Fraud_Types;
0
 

Author Closing Comment

by:jad0083
ID: 31545787
Exactly what I needed, i guess i just forgot to add it in the rowsource, thanks for the assistance!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question