| | |
how to retrieve data
![]() |
•
•
Join Date: Apr 2009
Posts: 8
Reputation:
Solved Threads: 0
i'm new programmer. can u help me , how to retrieve data from database(access) and display in combo box. the value in combo box will automatic display into text box
example:
dtbs=office.mdb
table name= item
field name=itemID,itemName
itemID=M1; itemName=modem
itemID=M2; itemName=repeater
i want this combo box display all itemID in combo box. if the user choose/click, M1, text box will display 'modem' automatically....
how to do like that???plzz help me.....
example:
dtbs=office.mdb
table name= item
field name=itemID,itemName
itemID=M1; itemName=modem
itemID=M2; itemName=repeater
i want this combo box display all itemID in combo box. if the user choose/click, M1, text box will display 'modem' automatically....
how to do like that???plzz help me.....
•
•
Join Date: Apr 2009
Posts: 8
Reputation:
Solved Threads: 0
this example for text box,but now i using combo box (style drop down list).
how to do that???
how to do that???
•
•
•
•
i'm new programmer. can u help me , how to retrieve data from database(access) and display in combo box. the value in combo box will automatic display into text box
example:
dtbs=office.mdb
table name= item
field name=itemID,itemName
itemID=M1; itemName=modem
itemID=M2; itemName=repeater
i want this combo box display all itemID in combo box. if the user choose/click, M1, text box will display 'modem' automatically....
how to do like that???plzz help me.....
set properties :-
combox box : name --> cboItem
style --> 2- dropdown list
textbox : name --> txtname
add this reference in the project --> Microsoft Activex Data Object <version no.> Library.......the version no. depends on the version of ms office u have installed.....take the highest one for better performance....
here we go...
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Option Explicit Dim gcn As New ADODB.Connection Private Sub cboItem_Click() Dim rs As New ADODB.Recordset With rs .CursorLocation = adUseClient .LockType = adLockOptimistic .CursorType = adOpenDynamic .Open "select itemname from [item] where itemid='" & cboItem.List(cboItem.ListIndex) & "'", gcn txtname.Text = IIf(.RecordCount = 0, "", IIf(IsNull(!itemname), "", !itemname)) End With If rs.State = adStateOpen Then rs.Close Set rs = Nothing End Sub Private Sub Form_Load() On Error GoTo err1 gcn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\sample.mdb;" & _ "Persist Security Info=False" gcn.Open Call PopulateCombo Exit Sub err1: Err.Clear MsgBox "Could not open database.", vbCritical, "Error" If gcn.State = adStateOpen Then gcn.Close Set gcn = Nothing End Sub Private Sub PopulateCombo() Dim rs As New ADODB.Recordset rs.CursorLocation = adUseClient rs.LockType = adLockOptimistic rs.CursorType = adOpenDynamic rs.Open "select itemid from [item] order by itemid", gcn With cboItem .Clear .AddItem "Select an Item Id" .ListIndex = 0 If rs.RecordCount > 0 Then rs.MoveFirst While Not rs.EOF() .AddItem rs!itemid rs.MoveNext Wend .ListIndex = 1 End If End With If rs.State = adStateOpen Then rs.Close Set rs = Nothing End Sub Private Sub Form_Unload(Cancel As Integer) If gcn.State = adStateOpen Then gcn.Close Set gcn = Nothing End End Sub
please let me know if this works out for you....for any more questions feel free to ask...
regards
Shouvik
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Have a problem? Don't worry just give me a call and I'll fix it for you.
![]() |
Similar Threads
- retrieve data from database into jsp(urgent)!!! (Oracle)
- How to retrieve all data and pass it (MS SQL)
- retrieve data (MS SQL)
- how to store and retrieve data from cookies (ASP.NET)
- VB.Net: Problem Retrieve data from ListView (VB.NET)
- How to retrieve data from a dynamically generated radio button (ASP.NET)
- retrieve data by VB.Net (VB.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Split PDF using Vb6
- Next Thread: Adding value of two rptfunction
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows






