Adding a Table on the

This code uses a pass-through query to tell Access to run a Create Table command:

Sub ADOCreateReplenish()

' This creates tblReplenish 1 There are five fields: 1 Style

' A = Auto replenishment for A

1 B = Auto replenishment level for B stores

' C = Auto replenishment level for C stores

1 RecActive = Yes/No field

Dim cnn As ADODB.Connection

Dim cmd As ADODB.Command

' Define the connection MyConn = "J:\transfers.mdb"

' open the connection

Set cnn = New ADODB.Connection

With cnn

.Provider = "Microsoft.Jet.OLEDB.4.0" .Open MyConn End With

Set cmd = New ADODB.Command Set cmd.ActiveConnection = cnn 'create table cmd.CommandText = "CREATE TABLE tblReplenish (Style Char(10) Primary Key,

A int, B int, C Int, RecActive YesNo)" cmd.Execute , , adCmdText Set cmd = Nothing Set cnn = Nothing Exit Sub End Sub

0 0

Post a comment