hi to all

combo1.additem "male"
cobmo1.additem"female"

combo2.additem" Educated"
combo2.additem"Uneducated"

even i have added in LIST property of combobox.

my problem is when i retrieve records from database for Find command button i am geting error as "Text" property is read-only. runtime error '383'. i want to dislplay FIND record details and rest LIST Items also, so that i can update the reocrd.


private sub cmdfind_click()

num = InputBox("Enter The Slno To Find The Kafill Details?", "Find")
rs1.Open "Select * from employee where EMP_NO='" & num & "'", con, adOpenStatic, adLockOptimistic

If rs1.RecordCount > 0 Then

Text2.Text = rs1.Fields(0) ' emp_no
Text3.Text = rs1.Fields(1) 'emp_firstname
Combo1.Text = rs1.Fields(7) 'gender
Combo2.Text = rs1.Fields(8) 'religion

Else

MsgBox "Record Not Found Please Try Next Time", vbCritical, "No-Records..."
Exit Sub
End If
rs1.Close
End Sub

Hi,

Unlike ListBox, u cant set the "Text" Property of a ComboBox, especially when its Style property is set to DropDown List.
U have to loop thru the List Items and make it selected.
Check this :

Dim i As Integer
 Dim str1 As String 
 str1 =RS1.Fields(7)
 For i= 0 To Combo1.ListCount -1
    If Trim(Combo1.List(i)) = Trim(str1) Then
       Combo1.ListIndex = i
       Exit For
    End If
 Next

Regards
Veena

u can do it in a alter(simple) way
Combo1.additem rs1.Fields(7)
combo1.listindex=combo1.listcount-1

Hi Anto_nee,


Why add one more Item to the List , When already that item is present in the List..?

More over ur logic will not work, if the Combo's Sorted property is True, Coz, after adding to combo, u cannot gaurantee that the added item will be the last or first item, Combo re--sorts itself..

Regards
Veena

yah veena

i just forgot about the sorting and the combo already have those values

i thought he need to add and show

so it should come last to the combo

sorting - i missed this item and found wrong in my statement

sorry veena

take care

Hai,
i am priya,i have a doubt in VB6.0 with Access,How to create a ComboBox,and it want to add his field value to display in the combo box...

And Other Doubt i have that how to create a CrystalReport with Excel...in VB6.0

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.