lewy the fly
New Member
- Joined
- Mar 6, 2011
- Messages
- 5
I have the following module used to import data from a access data base, however I only want it to work if the C9 is equal to zero. can any one help with the required code.
Sub Insert_Data()
'
' Insert_Data Macro
' Insert Data from Cabnet Vision Macro recorded 12/09/2004 by Lewis
'
' Keyboard Shortcut: Ctrl+i
'
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\Planit\Solid_5_0\Database\db1.mdb;DefaultDir=C:\Planit\Solid_5_0\Database;DriverId=25;FIL=M" _
), Array("S Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:=Range( _
"Q3"))
.CommandText = Array( _
"SELECT `Parts Query`.`Cabinet ID`, `Parts Query`.`Width String`, `Parts Query`.`Length String`, `Parts Query`.Description, `Parts Query`.Name, `Parts Query`.Typ" _
, "e" & Chr(13) & "" & Chr(10) & "FROM `C:\Planit\Solid_5_0\Database\db1`.`Parts Query` `Parts Query`")
.Name = "Query from MS Access Database_4"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\Planit\users\administrator\REPORT.MDB;DefaultDir=C:\CabinetVision\Solid\Database;DriverId=281;F" _
), Array("IL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:= _
Range("B65"))
.CommandText = Array( _
"SELECT `Job Info`.`Job Number`" & Chr(13) & "" & Chr(10) & "FROM `C:\Planit\users\administrator\REPORT`.`Job Info` `Job Info`" _
)
.Name = "Query from MS Access Database_19"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
Call FilterMaterials
End With
End With
End Sub
Regards Lewy
Sub Insert_Data()
'
' Insert_Data Macro
' Insert Data from Cabnet Vision Macro recorded 12/09/2004 by Lewis
'
' Keyboard Shortcut: Ctrl+i
'
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\Planit\Solid_5_0\Database\db1.mdb;DefaultDir=C:\Planit\Solid_5_0\Database;DriverId=25;FIL=M" _
), Array("S Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:=Range( _
"Q3"))
.CommandText = Array( _
"SELECT `Parts Query`.`Cabinet ID`, `Parts Query`.`Width String`, `Parts Query`.`Length String`, `Parts Query`.Description, `Parts Query`.Name, `Parts Query`.Typ" _
, "e" & Chr(13) & "" & Chr(10) & "FROM `C:\Planit\Solid_5_0\Database\db1`.`Parts Query` `Parts Query`")
.Name = "Query from MS Access Database_4"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
With ActiveSheet.QueryTables.Add(Connection:=Array(Array( _
"ODBC;DSN=MS Access Database;DBQ=C:\Planit\users\administrator\REPORT.MDB;DefaultDir=C:\CabinetVision\Solid\Database;DriverId=281;F" _
), Array("IL=MS Access;MaxBufferSize=2048;PageTimeout=5;")), Destination:= _
Range("B65"))
.CommandText = Array( _
"SELECT `Job Info`.`Job Number`" & Chr(13) & "" & Chr(10) & "FROM `C:\Planit\users\administrator\REPORT`.`Job Info` `Job Info`" _
)
.Name = "Query from MS Access Database_19"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = True
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
Call FilterMaterials
End With
End With
End Sub
Regards Lewy