-
Jan 24th, 2018, 01:58 PM
#1
Thread Starter
Hyperactive Member
-
Jan 24th, 2018, 08:01 PM
#2
Re: Error while executing a VBA Code to get MS Access database table field details ..
Guess what i did:
i copied your ListTablesAndFields sub
and pasted it in an access 2003 module with the Northwind.mdb (access 2000 file format)
and it did exactly what it is supposed to do
do not put off till tomorrow what you can put off forever
-
Jan 25th, 2018, 02:28 PM
#3
Thread Starter
Hyperactive Member
Re: Error while executing a VBA Code to get MS Access database table field details ..
I am using MS Access 2013 Database (Test.accdb). Do I need to mention database name in that code?
Note: My Database is password protected.
Last edited by VS2013; Jan 25th, 2018 at 04:19 PM.
-
Jan 27th, 2018, 03:24 PM
#4
Thread Starter
Hyperactive Member
Re: Error while executing a VBA Code to get MS Access database table field details ..
I tried but getting the same error. May be becuase of File Format it throws that error. Or any refence file is missing.
-
Jan 28th, 2018, 06:13 AM
#5
Re: Error while executing a VBA Code to get MS Access database table field details ..
maybe you could say where in the code that error is occuring
also, i just noticed : Dim dBase As Database
'Database' is a DAO object
yet i do not see any reference to DAO
but i do see a reference to Microsoft Office 15.0 Access database engine Object
what i think is a reference to ACEDAO (i can not be sure of that,since i do not have access 2013)
so just try putting in a reference to DAO, and giving it a high priorety (higher then ADO)
do not put off till tomorrow what you can put off forever
-
Jan 29th, 2018, 01:55 PM
#6
Re: Error while executing a VBA Code to get MS Access database table field details ..
As the example doesnt have a password, try taking off the password. See if it affects it
If it does, then you will probably need to amend the open database line. Shouldnt affect it though.
You dont need ADO if you are already in Access (unless you need it elsewhere?)
Did the error show a particular line ?
Not sure you need powerpoint, outlook, office... depends what you are doing
Excel reference isnt really required as you can use:
Code:
dim objXL as object
set objXL = createObject("excel.application")
sort of thing, but as its a first time trying it, leave it in.
Just be aware that vba sometimes gets confused when there are functions with the same name if you arent explicitly declaring them when using...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jan 29th, 2018, 06:07 PM
#7
Re: Error while executing a VBA Code to get MS Access database table field details ..
Guess what happened today
the granddaughter that has access 2010 on her laptop came by today
so,i copied your ListTablesAndFields sub
and pasted it in an access 2010 module with the NWIND.ACCDB database
and it did exactly what it is supposed to do
so,i am willing to bet a box of chocolates it will work on any version of access
(at least from 2000 on)
do not put off till tomorrow what you can put off forever
-
Jan 29th, 2018, 09:06 PM
#8
Re: Error while executing a VBA Code to get MS Access database table field details ..
Originally Posted by VS2013
The following is the code written in Module:
What you didn't mention was the name of the Module you created...I just wonder if you called it "Database" by chance.
-tg
-
Jan 30th, 2018, 06:27 AM
#9
Re: Error while executing a VBA Code to get MS Access database table field details ..
Hi,
with a Name like VS2013, why not use VS
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=D:\Northwind.mdb")
Dim Tablename As String = "Orders"
con.Open()
Dim DT As DataTable = con.GetSchema("Tables")
Dim Cmd As OleDbCommand = con.CreateCommand()
Dim dr As OleDbDataReader
With Cmd
.CommandText = "Select * From " & Tablename
.CommandType = CommandType.Text
dr = .ExecuteReader
End With
DT = dr.GetSchemaTable
con.Close()
DataGridView1.DataSource = DT
End Sub
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Feb 3rd, 2018, 01:50 AM
#10
Thread Starter
Hyperactive Member
Re: Error while executing a VBA Code to get MS Access database table field details ..
-
Feb 10th, 2018, 01:17 AM
#11
New Member
Re: [RESOLVED] Error while executing a VBA Code to get MS Access database table field
Thanks all for your support and get me out for this.
Vegetarian Foods
Last edited by rabiyajamal45; Oct 23rd, 2023 at 04:09 AM.
-
Feb 11th, 2018, 04:53 AM
#12
Lively Member
Re: Error while executing a VBA Code to get MS Access database table field details ..
Originally Posted by ChrisE
Hi,
with a Name like VS2013, why not use VS
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=D:\Northwind.mdb")
Dim Tablename As String = "Orders"
con.Open()
Dim DT As DataTable = con.GetSchema("Tables")
Dim Cmd As OleDbCommand = con.CreateCommand()
Dim dr As OleDbDataReader
With Cmd
.CommandText = "Select * From " & Tablename
.CommandType = CommandType.Text
dr = .ExecuteReader
End With
DT = dr.GetSchemaTable
con.Close()
DataGridView1.DataSource = DT
End Sub
regards
Chris
hi, i just copied this and pasted it in visual basic 2015
got the following errors:
Type 'OleDbCommand' is not defined
Type 'OleDbConnection is not defined
Type 'OleDbConnection is not defined
Type 'OleDbDataReader' is not defined
what's going on ? what am i missing
-
Feb 11th, 2018, 06:16 AM
#13
Re: [RESOLVED] Error while executing a VBA Code to get MS Access database table field
Hi,
add this to your Form...
Code:
Option Strict On
Imports System.Data.OleDb
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.jet.oledb.4.0;data source=D:\Northwind.mdb")
Dim Tablename As String = "Orders"
con.Open()
Dim DT As DataTable = con.GetSchema("Tables")
Dim Cmd As OleDbCommand = con.CreateCommand()
Dim dr As OleDbDataReader
With Cmd
.CommandText = "Select * From " & Tablename
.CommandType = CommandType.Text
dr = .ExecuteReader
End With
DT = dr.GetSchemaTable
con.Close()
DataGridView1.DataSource = DT
End Sub
regards
Chris
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|