Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Help

Status
Not open for further replies.

jmagee

Mechanical
Nov 14, 2001
35
US
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?
 
Replies continue below

Recommended for you

Are you using the adodc control? If so, this control has a visable property that you can select false.

Hope this helps.

Christina
 
I know that I can hide the ADO control, but thats not what my question was.
 
Hi,

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
 
I hope that this is a little clearer.
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.
 
jmagee,

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 &quot;Provider=Microsoft.Jet.OLEDB.3.51;Data Source=c:\example.mdb&quot;

' 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 = &quot;'&quot; + dropdown.text + &quot;'&quot; 'Use the Text value of drop down list here. Be sure to add the single quotes
rs1.Open &quot;Select * From ExampleTableName Where ExampleColumn = &quot; + 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

 
How can I open a dynamic recordset in VB for an Access database? I am using ADO and I want to be able to use ado_recordset.MovePrevious.

Thanks,
Jordan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top