ADO Help
ADO Help
(OP)
I have a small VB App that I'm currently writing that has an ADO control that controls a Dropdown Box as well as a Textbox. They work great using the ADO control, however, I want to hide the ADO Control and use just the selections from the Dropdown box to drive the correct results in the Textbox. Can anyone steer me in the right direction with some code snippets to accomplist this task?
RE: ADO Help
Hope this helps.
Christina
RE: ADO Help
RE: ADO Help
So what is your question ?. Do you want to hide the ADO control or you want to do it without using an ADO control.
Because if its the former then whats wrong with the former post.
If its the latter then what are you selecting in the drop down box and what effect do you want on the text box ?
Any help ?, yes no let me know.
Regards
RE: ADO Help
I have hidden my ADO control on my GUI.
Currently my dropdown Box is populated by the ADO control,
as well as the texstbox, and they work well together using ADO.
But what I actually want is instead of using the ADO control to populate the textbox, I want to select an item in the dropdown box and have the correct field from my .mdb file displayed in the textbox, just as it is when I use the ADO control.
Any help will be greatly appreciated.
RE: ADO Help
If you are going to make the ADO Data control invisible, what is the need to include it in the form ? You can do all database accesses programmatically.
First make a reference to Microsoft ActiveX Data Objects 2.1 Library from the <Project> <References> menu. (My version is 2.1, yours may be different).
***********CODE STARTS HERE*****************
Dim cnn1 as ADODB.Connection
Dim rs1 as ADODB.Recordset
Dim strFind as String
Set cnn1 = New ADODB.Connection
cnn1.ConnectionString "Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\example.mdb"
' If mdb file is Access 2000, you should use 4.0 instead of 3.51
cnn1.CursorLocation = adUseClient 'Client side cursor
cnn1.Open 'Open the connection
Set rs1 = New ADODB.Recordset
strFInd = "'" + dropdown.text + "'" 'Use the Text value of drop down list here. Be sure to add the single quotes
rs1.Open "Select * From ExampleTableName Where ExampleColumn = " + strFInd, cnn1, adOpenDynamic, adLockBatchOptimistic
'If there is only one matching record, you can assign its value to the text box like this
textbox.text= rs1.fields(1) 'Second column.
'Then unload the objects
Set cnn1 = Nothing
Set rs1 = Nothing
***********CODE ENDS HERE****************************
Hope this helps,
Sajith
RE: ADO Help
Thanks,
Jordan