|
-
Jan 30th, 2002, 04:46 PM
#1
Thread Starter
Lively Member
Here's a simple, down and dirty solution.
When you create your form, add a 2nd combo box, set visible=false and populate it with the field data you want at the same time you populate your actual combo box. Then, in the actual combo box's click event, do this:
cboDummy.ListIndex = cboActual.ListIndex
Your dummy combo box will always hold the field data you want.
-
Jan 30th, 2002, 04:57 PM
#2
Addicted Member
Another way you can do this is to use the ItemData property of the list box.
VB Code:
With Combo1
.Additem rs!Field1
.ItemData(.NewIndex)=rs!Field2
End With
'Then when you select an entry
Label1=Combo1.ItemData(Combo1.ListIndex)
-
Jan 31st, 2002, 12:26 PM
#3
Junior Member
Private Sub Combo3_Change()
With Combo3
.Additem rs!Field1
.ItemData(.NewIndex) = rs!Field2
End With
'Then when you select an entry
Label35 = Combo3.ItemData(Combo3.ListIndex)
End Sub
-
Jan 31st, 2002, 12:32 PM
#4
Junior Member
Private Sub Combo3_Change()
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase("c:\windows\desktop\Visual Basic Projects\Bst_Drawing.mdb")
Set rs = db.OpenRecordset("SELECT * " & _
"FROM Document_Type ")
'Label35.Caption = rs = abreviation
With Combo3
.Additem rs!Field1
.ItemData(.NewIndex) = rs!Field2
End With
'Then when you select an entry
Label35 = Combo3.ItemData(Combo3.ListIndex)
End Sub
I'm getting a method or data member not found error for the ".AddItem"
Which Field is the one from the combo box and which one is the data I'm trying to extract?
-
Jan 31st, 2002, 12:38 PM
#5
Junior Member
Private Sub Combo3_Change()
'Dim db As Database
'Dim rs As Recordset
'Set db = OpenDatabase("c:\windows\desktop\Visual Basic Projects\Bst_Drawing.mdb")
'Set rs = db.OpenRecordset("SELECT * " & _
"FROM Document_Type ")
'Label35.Caption = rs = abreviation
With Combo3
.Additem rs!Abbreviation
.ItemData(.NewIndex) = rs!Document_Type
End With
'Then when you select an entry
Label35 = Combo3.ItemData(Combo3.ListIndex)
End Sub
This particular bit of code removes the list I am choosing from and call up a dialog box that requests the "Document_type.Document_Type"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|