hey i am new to visual basic programming...just 15-20 days into it...
i wanna know how can i use command button to access the ms access files instead of using the data control....how can i do that????
i have tried a lot of things but to no effect .... please help me with this!!!!
i tried to find this solution in the solved threads but without any success.

Hi,

Add "Microsoft ActiveX objects 2.0" References to the project.
use this code:

Dim rs As New ADODB.Recordset
Dim AC As New ADODB.Connection
With AC
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDB.mdb;Persist Security Info=False"
.Open
End With
ssql = "Select * from MyTable"
Set rs=Nothing
RS.Open ssql,AC
If RS.EOF Then
  ' No Record Found
Else
  'Records Found
End If

Regards
Veena

hey....
thanks for the code but on command click its not showing the records in the textboxes...
do i have to do anything...for that...likeways changing the properties..
thanks...

Hi,

In continuation with above code:

If RS.EOF Then
' No Record Found
Else
text1.text = RS(0)
text2.text = RS(1)
text3.text = RS(2)
text4.text = RS(3)
text5.text = RS(4)
End If


Regards
Veena

thanks !!!!
it worked.....

what bout try yourself before ask for help and if possibel posting your code instead of asking for complete solution.

i tried it my self quite a lot....
but just couldnt get the solution....
i know the rules .... sure dude....dont get angry...
i checked all the threads....but jus couldt get over..it....
i actully am a new programmer and dont kno much..
i just got as far as using a data control.....got it!

hey i am new to visual basic programming...just 15-20 days into it...
i wanna know how can i use command button to access the ms access files instead of using the data control....how can i do that????
i have tried a lot of things but to no effect .... please help me with this!!!!
i tried to find this solution in the solved threads but without any success.

Why do you want to use the command button instead of a data control? Coz if you'll do that and then if you have another command you'll have to call/access again the database. the advantage of the data control is that you only ask the data control to display the data you wanted without "connecting again" to the database... just an opinion/thought hehehe, please don't get me wrong:$

thanx for your opinion....
but i guess data control has some limitations...
i may be wrong though.....
kindly guide me.....

thanx for your opinion....
but i guess data control has some limitations...
i may be wrong though.....
kindly guide me.....

yeah! you cannot put them in modules hehehe I use controls than declaring variables to lessen the code so that it more readable. but of course I use variables too but only when needed. So how's your project now?
By the way are you using

Option Explicit

in your vb?

i'll show you my code but its all messed up right no........:(
but i have bought a black book on vb6.......:)
i'll contact you as soon as i get it in a better shape...
thanks for your concern:)

i'll show you my code but its all messed up right no........:(
but i have bought a black book on vb6.......:)
i'll contact you as soon as i get it in a better shape...
thanks for your concern:)

Have you tried the book of Diethel and Diethel? the're good, very friendly to the newbies...

adoRecordset.Open "select Project_Name,BU from Risk_Analysis", db2, adOpenStatic, adLockOptimistic

why am i gettin an error which says "object required" in this line

Hi,

Check the following:

DB2 ADO Connection Object is open or not.
Declare RST
Dim RST As New ADODB.Recordset
Set RST=Nothing
RST.Open "select Project_Name,BU from Risk_Analysis", db2, adOpenStatic, adLockOptimistic

Regards
Veena

commented: thanks.... +1

what's the use of it???
i have no idea....

hurray.....
i have completed the basic structure of my project...:P
thanx to all who have helpd me....
special thanks to jireh and qveen(veena)......

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.