HI,
There are two things:-
1) If CategoryName is unique in table, U can write a Function which takes CategoryName as parameter and returns CategoryID.
Like ....
In Click event of Combo
Text6.text = GetCategoryID(Combo1.text)
Public Function GetCategoryID(ByVal CategoryName as String)
Dim Rs as New ADODB.RecordSet
Dim Sql As string
Sql= "Select catID from table1 where CatName ='"
Sql=Sql+trim(Combo1.text))+"'"
Set Rs = Con.Execure (Sql)
If Rs.Eof()=false then
GetCategoryID = Rs("CateId")
Else
GetCategoryID = "" '''0 if numeric type
Endif
Rs.Close
Set Rs = nothing
End Function
---------------------
And If Categoryname is not unique then
----------------------------
rsCat.MoveFirst
Do Until rsCat.EOF
Combo1.AddItem rsCat("CATEGORYNAME")+"*"+RsCat("CatId")
''If Numeric type then use Cstr with CatID
rsCategory.MoveNext
Loop
In Click event of Combo
Dim TempArray
TempArray = Split(Trim(Combo1.Text),"*")
Text6.Text = Trim(TempArray(1))
Gud Luck
B. Anant
|