Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

trying to open an access database

Status
Not open for further replies.

Zeroanarchy

Technical User
Jun 11, 2001
630
0
0
AU
I dont seem to get any errors but the problem is nothing happens, no go opens nothing.

Private Sub sampleLabel_Click(Index As Integer)
Dim db As Database
Set db = OpenDatabase("C:\security.mdb")
End Sub

and have changed the reference to:
Microsoft DAO 3.6 object library


any ideas?

Thanks Zero
 
Hi Zeroanarchy,
I think its best to use ADO.DAO are things of the past and ADO gives you bothe the fuctionalites of DAO as well as RDO.
 
carnt seem to find the ado.dao reference is it under a diffrent name or can I browse for it and find it in a specific directory?

Thanks Zero
 
. I created a setup file in VB using deployment wizard.When i installing that setup file i am getting
"c:\win98\temp\msftq.pdw\$(DLLselfregister) could't be registerd bcose it is not found" ERROR.(I installed DCOM98 fully on my mechine
 
Zeroanarchy,
I believe what 12041977 meant was the ADO reference. It's called Microsoft ActiveX Data Objects in the references. After you change to this reference you can use something like this: Create & open a new connection (this will work as a connection string "PROVIDER=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Security.mdb") Then you can check the state of the connection object. Connection state is in one of the VB samples.
Hope this helps you out.
 
Hi Zeroanarchy try this code:

Private wrkDefault As Workspace
Private dbsNew As Database
Private tdfNew As New TableDef

Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNew = wrkDefault.CreateDatabase("MDB.mdb", _
dbLangGeneral, dbEncrypt)
Set dbsNew = wrkDefault.OpenDatabase("MDB.mdb", True, False) 'open the created Database
Set tdfNew = dbsNew.CreateTableDef("TableName")
with tdfNew
.Fields.Append .CreateField("Feild1",dbtext) 'Create a new field
end with
dbsNew.TableDefs.Append tdfNew 'add the table to the DB

dbsNew.Close 'close db

The above will create a database, table and field. u can use the following code to populate the tables

Dim cnn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim strcnn As String

cnn.ConnectionString = "ODBC;DBQ="MDBFile.mdb" & ";UID=;PWD=;Driver={Microsoft Access Driver (*.mdb)}"

cnn.open
Set rs = New ADODB.Recordset
set rsNew=New ADODB.Recordset

strcnn="SELECT * FROM TableName"
rsNew.open strcnn, cnn, adOpenDynamic, adLockOptimistic
rsNew.addNew
rsNew.fields("FieldName") ="Hello"
rsNew.close

set rs=Nothing
set rsNew=Nothing


Hope this works.
Let me know if u need more information.

Thanks

PS: Make sure to have a referance MS DAO 3.6 Library and MS ADO 2.5 Murali Bala
 
ok well tried all the above options, I do believe that I may have not made my self clear I do not want visual basic to be linked to Access all I am trying to do is open access by itself, in other works just create a link that open security.mdb on a click and shuts down the vb form.

so far I have tried

Shell, the problem with this option is you have to know exactly where the user has put access on there computer

Dim RetVal
RetVal = Shell("access.exe" "c:\security.mdb", 0)

I have tried

Set wrkDefault = DBEngine.Workspaces(0)
Set dbs = wrkDefault.OpenDatabase("c:\security.mdb", True, False)

End Sub

I have tried

Private Sub sampleLabel_Click(Index As Integer)
Dim db As Database
Set db = OpenDatabase("C:\security.mdb")
End Sub

using the DAO reference and the active X reference.

Still no go, any other thoughts.

zero
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top