473,467 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Linking MS SQL tables into MS Access 2003 VBA - too many indexes

4 New Member
Hello,
I have a 3rd party app that uses SQL server to store its data. I am also creating a MS Access 2003 app to access the data. When I import the tables a few of the tables have over the 32 index limit. Is there a way to link the tables without indexes or count the amount of indexes and stop after set amount during the import? I cannot change the indexes in SQL because they are used by 3rd party app so I need a way to access the tables and link them; getting around this problem of 32 index limit. THANK YOU.
Aug 22 '07 #1
3 4008
Jim Doherty
897 Recognized Expert Contributor
Hello,
I have a 3rd party app that uses SQL server to store its data. I am also creating a MS Access 2003 app to access the data. When I import the tables a few of the tables have over the 32 index limit. Is there a way to link the tables without indexes or count the amount of indexes and stop after set amount during the import? I cannot change the indexes in SQL because they are used by 3rd party app so I need a way to access the tables and link them; getting around this problem of 32 index limit. THANK YOU.
Hi

How are you accessing the data? what is your frontend file format? unless you specifically Neeeeeeeeed to import tables to a localised copy of a database (mdb format) my advice is to use an MS ADP project to access SQL server that way all the table remain on the server

Regards

Jim
Aug 22 '07 #2
asorkoram
4 New Member
Hi Jim,

I have to link the table in MS Access not a access data page. I have to do all types of reports and also upgrades are done to the SQL data tables and I have to be able to read all that to change forms in my Access app. I have been able to Link the tables but it copies all the Index info aswell...My code:

Public Function MakeLinkODBC(ServerName As String, _
DNSName As String, _
DatabaseName As String, _
UserName As String, _
UserPass As String) As Boolean

On Error GoTo errODBC
Dim SQLDb As DAO.Database
Dim dbLocal As DAO.Workspace
Dim I As Long
Dim tblName As String
Dim tdfCurrent As DAO.TableDef
Dim nbrTable As Long
Dim idx As DAO.Index

Dim ind As DAO.Index 'Each index of this table.
Dim fld As DAO.Field 'Each field of the index
Dim iCount As Integer
Dim strReturn As String 'Return string
Dim tdf As DAO.TableDef 'Name of table
Dim tdfS As String
Dim ind1 As Index


Set dbLocal = DBEngine.Workspaces(0)
Set SQLDb = dbLocal.OpenDatabase("", dbDriverNoPrompt, False, "ODBC;DATABASE=" & DatabaseName & _
";UID=" & UserName & _
";PWD=" & UserPass & _
";DSN=" & DNSName & _
";SERVER=" & ServerName & "")
nbrTable = SQLDb.TableDefs.Count - 1
Dim Z
Dim x
Dim j

x = 0
For I = 0 To nbrTable
tblName = SQLDb.TableDefs(I).Name



Call UpdateProgressMeter("M1 Conversion and Linking Prog :" & vbCrLf & DatabaseName & " now doing...", I, Val(nbrTable), "M1 Progress Linking form", I & "/" & nbrTable)

'Add the
If SQLDb.Name = "Master" Then

If InStr(tblName, ".") > 0 Then
tblName = Right(tblName, Len(tblName) - InStr(tblName, "."))
End If

Set tdfCurrent = CurrentDb.CreateTableDef(tblName, dbAttachSavePWD)
tdfCurrent.Connect = "ODBC;DATABASE=" & DatabaseName & ";UID=" & UserName & ";PWD=" & UserPass & ";DSN=" & DNSName


If tblName = "sysprocesses" Then
tdfCurrent.SourceTableName = tblName
CurrentDb.TableDefs.Append tdfCurrent
End If

Else

'// Exclude the systems objects
If Left(tblName, 1) <> "~" And InStr(tblName, ".sys") = 0 Then
If InStr(tblName, ".") > 0 Then
tblName = Right(tblName, Len(tblName) - InStr(tblName, "."))
End If
If tblName = "PartMemos" Then

'MsgBox ("1")
Set tdfCurrent = CurrentDb.CreateTableDef(tblName, dbAttachSavePWD)
'MsgBox ("2")

tdfCurrent.Connect = "ODBC;DATABASE=" & DatabaseName & ";UID=" & UserName & ";PWD=" & UserPass & ";DSN=" & DNSName
'MsgBox ("3")

'Proccess the tables and views and do name change
If InStr(tblName, "dbo") = 0 Then
'Do just tables
'
'MsgBox ("4")
tdfCurrent.SourceTableName = tblName

MsgBox ("Start Section")

CurrentDb.TableDefs.Append tdfCurrent
MsgBox ("Did It!!")

'Rename the DD tables to "System_DD
CurrentDb.TableDefs(tblName).Name = Replace(CurrentDb.TableDefs(tblName).Name, "DD", "M1DD_")

Else
'Do all the views for the tables
tdfCurrent.SourceTableName = tblName
CurrentDb.TableDefs.Append tdfCurrent
End If

End If

End If

End If
Next I

SQLDb.Close
dbLocal.Close

MakeLinkODBC = True
Forms![frmSetup-ODBC]![Annuler].Caption = "Close"

Exit Function

errODBC:
If Err.Number = 3010 Then 'Object already exists
Resume Next
ElseIf Err.Number = 3265 Then
Resume Next
ElseIf Err.Number = 3059 Then
MakeLinkODBC = False
Exit Function
Else
MsgBox Err.Description, vbExclamation, "SQL Server"
MakeLinkODBC = False
Exit Function
End If

End Function

My app gets the error where it says MsgBox ("Start Section")
The error is "There are too many index in Table "PartMemos"

Isn't there a way to separate out the fields and data from the Indexes??

Thanks, Ayal
Aug 23 '07 #3
Jim Doherty
897 Recognized Expert Contributor
Hi Jim,

I have to link the table in MS Access not a access data page. I have to do all types of reports and also upgrades are done to the SQL data tables and I have to be able to read all that to change forms in my Access app. I have been able to Link the tables but it copies all the Index info aswell...My code:

Public Function MakeLinkODBC(ServerName As String, _
DNSName As String, _
DatabaseName As String, _
UserName As String, _
UserPass As String) As Boolean

On Error GoTo errODBC
Dim SQLDb As DAO.Database
Dim dbLocal As DAO.Workspace
Dim I As Long
Dim tblName As String
Dim tdfCurrent As DAO.TableDef
Dim nbrTable As Long
Dim idx As DAO.Index

Dim ind As DAO.Index 'Each index of this table.
Dim fld As DAO.Field 'Each field of the index
Dim iCount As Integer
Dim strReturn As String 'Return string
Dim tdf As DAO.TableDef 'Name of table
Dim tdfS As String
Dim ind1 As Index


Set dbLocal = DBEngine.Workspaces(0)
Set SQLDb = dbLocal.OpenDatabase("", dbDriverNoPrompt, False, "ODBC;DATABASE=" & DatabaseName & _
";UID=" & UserName & _
";PWD=" & UserPass & _
";DSN=" & DNSName & _
";SERVER=" & ServerName & "")
nbrTable = SQLDb.TableDefs.Count - 1
Dim Z
Dim x
Dim j

x = 0
For I = 0 To nbrTable
tblName = SQLDb.TableDefs(I).Name



Call UpdateProgressMeter("M1 Conversion and Linking Prog :" & vbCrLf & DatabaseName & " now doing...", I, Val(nbrTable), "M1 Progress Linking form", I & "/" & nbrTable)

'Add the
If SQLDb.Name = "Master" Then

If InStr(tblName, ".") > 0 Then
tblName = Right(tblName, Len(tblName) - InStr(tblName, "."))
End If

Set tdfCurrent = CurrentDb.CreateTableDef(tblName, dbAttachSavePWD)
tdfCurrent.Connect = "ODBC;DATABASE=" & DatabaseName & ";UID=" & UserName & ";PWD=" & UserPass & ";DSN=" & DNSName


If tblName = "sysprocesses" Then
tdfCurrent.SourceTableName = tblName
CurrentDb.TableDefs.Append tdfCurrent
End If

Else

'// Exclude the systems objects
If Left(tblName, 1) <> "~" And InStr(tblName, ".sys") = 0 Then
If InStr(tblName, ".") > 0 Then
tblName = Right(tblName, Len(tblName) - InStr(tblName, "."))
End If
If tblName = "PartMemos" Then

'MsgBox ("1")
Set tdfCurrent = CurrentDb.CreateTableDef(tblName, dbAttachSavePWD)
'MsgBox ("2")

tdfCurrent.Connect = "ODBC;DATABASE=" & DatabaseName & ";UID=" & UserName & ";PWD=" & UserPass & ";DSN=" & DNSName
'MsgBox ("3")

'Proccess the tables and views and do name change
If InStr(tblName, "dbo") = 0 Then
'Do just tables
'
'MsgBox ("4")
tdfCurrent.SourceTableName = tblName

MsgBox ("Start Section")

CurrentDb.TableDefs.Append tdfCurrent
MsgBox ("Did It!!")

'Rename the DD tables to "System_DD
CurrentDb.TableDefs(tblName).Name = Replace(CurrentDb.TableDefs(tblName).Name, "DD", "M1DD_")

Else
'Do all the views for the tables
tdfCurrent.SourceTableName = tblName
CurrentDb.TableDefs.Append tdfCurrent
End If

End If

End If

End If
Next I

SQLDb.Close
dbLocal.Close

MakeLinkODBC = True
Forms![frmSetup-ODBC]![Annuler].Caption = "Close"

Exit Function

errODBC:
If Err.Number = 3010 Then 'Object already exists
Resume Next
ElseIf Err.Number = 3265 Then
Resume Next
ElseIf Err.Number = 3059 Then
MakeLinkODBC = False
Exit Function
Else
MsgBox Err.Description, vbExclamation, "SQL Server"
MakeLinkODBC = False
Exit Function
End If

End Function

My app gets the error where it says MsgBox ("Start Section")
The error is "There are too many index in Table "PartMemos"

Isn't there a way to separate out the fields and data from the Indexes??

Thanks, Ayal
Ayal,

Using an .ADP file frontend format does not mean you have to use data access pages!! I don't use them myself not much point! if you are going to web enable use ASP. With an ADP frontend you can have forms, views,reports macros menus modules in fact most everything that an MDB has.
Using an ADP means you have an built in connection to the server using datalink UDL connectivity. The big plus side here is that the tables remain on the server. You can SEE them in the tables windows as you would if you were using an MDB? and do whatever you need to. There is no setting up of ODBC connections locally or otherwise to contend with and you wouldnt have 'the too many indexes' issue you currently have trying to import table info and data into lesser data storage beast as is Access compared against the SQL Server environment.

Unless you have something else in mind there is no reports that I know of that cannot come off of an ADP file compared to an MDB with the exception of dead easy crosstab functionality and plus everything is server side so client connection overhead is to a minimum.

The simple answer to your problem currently is to 'reduce' the indexes on the server table causing the problem to keep within Access 'limitations' (32 in all) and try again?

Jim
Aug 23 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John South | last post by:
I have an Access 2000 front end that I wish to work with a SQL Server 2000 database by means of Linked tables. Do I have to use an ODBC connection to SQL Server? It seems to be the only option...
14
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after...
5
by: Christoph Sticksel | last post by:
Hi, I'm having problems with attaching two tables stored in an SQL Server 2000 to an Access 97 database. It worked well for all other tables except those two. This is what I did: Choose the...
10
by: Jennifer Carr | last post by:
I have an Access 2003 application that is split into two .mdb files for the interfaces and data. This app is distributed on a CD to be used on computers that have no internet access. When someone...
1
by: lochmant | last post by:
I have a series of about 10 test databases with about 34 linked table each. I need to create an Access 2003 database front end for each of these. I am currently trying to write a script that will...
3
by: TonyJH226 | last post by:
I’m using Access 2003 and am a novice to Access. I am creating a form to facilitate data entry to seven tables. The main table (A) has four sub-tables that are related to the main table by...
0
by: asorkoram | last post by:
Hello, I have a 3rd party app that uses SQL server to store its data. I am also creating a MS Access 2003 app to access the data. When I import the tables a few of the tables have over the 32 index...
0
by: asorkoram | last post by:
Hello, I have a 3rd party app that uses SQL server to store its data. I am also creating a MS Access 2003 app to access the data. When I import the tables a few of the tables have over the 32 index...
7
by: Salad | last post by:
I am converting an application from A97 to A2003. I have 2 tables created by another application as a Foxpro.dbf. The table has no index. The connect string in A97 is FoxPro...
16
by: Okonita via DBMonster.com | last post by:
Hi all, I am comming along with all this Linus/DB2/scripting business...I am no longer scared of it!! (LOL). But, I need to create a .ksh script that does a REORGCHK and output only tables...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.