LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Excel Import - data limitation

Hi,

I'm very lost. I've written a VB that used to work (but something must have
happened and it's not working as planned).

I have two excel files (one allows user to pick criteria, the second one
takes the imported table and creates a querytable out of it for user to
refresh. Data in 2nd file is also limited to what was requested in 1st file.

In file 1, user basically chooses the criteria from header fields from a
pivot table. A macro then sets up the filter to be used in SQL. Now, some
of the fields are not working. They may work when multiple criterias are
set. I'm guessing it's probably a size problem, but my file has a max of
10,000 records only.

Is there a problem with this code?

Public Sub RefreshTableData()
'Code goes to the Criteria tab to get filter information and uses this to
grab data from dba

On Error GoTo ERRORHANDLING
Dim strFilterCriteria As String
Dim counter As Integer
Dim intTotalFilters As Integer
Dim strFilterCriteria1 As String

'criteria is from row 2 to 24 = this should not change
'code below creates the filter info
Sheets(strCriteriaTabName).Activate
intTotalFilters = 0
For counter = 2 To 24
'don't filter if a field selection is all or if no fill is
identified in column A
If (Range("B" & counter).Value = "(All)" Or Range("a" &
counter).Value = "") Then
'do nothing
Else
intTotalFilters = intTotalFilters + 1
If intTotalFilters = 1 Then
strFilterCriteria = "WHERE "
Else
strFilterCriteria = strFilterCriteria & " AND "
End If
strFilterCriteria = strFilterCriteria & "(`" & QueryName &
"`." & Range("A" & counter).Value & "='" & Range("B" & counter).Value & "')"
End If
Next counter



'deletes old info from Salary Calculations tab and populates with
most recent data from query
Sheets(SalaryDetailsTab).Activate

Range("A65:L30000").Select
Selection.ClearContents
Selection.QueryTable.Delete

With ActiveSheet.QueryTables.Add(Connection:=Array(Arra y( _
"ODBC;DSN=MS Access Database;DBQ=I:\CONSOLIDATION UNIT\ACCESS
DATABASE\Members Salary Forecast.mdb;DefaultDir=I:\CONSOLIDATION UNIT\" _
), Array("ACCESS DATABASE;DriverId=25;FIL=MS
Access;MaxBufferSize=2048;PageTimeout=5;")) _
, Destination:=Range("A65"))

.CommandText = Array( _
"SELECT `" & QueryName & "`.Name, `" & QueryName & "`.REG, `" &
QueryName & "`.Rank_, `" & QueryName & "`.Collator, `" & QueryName & "" _
, "`.Collator_Desc, `" & QueryName & "`.Emp_Date, `" & QueryName
& "`.Step_, `" & QueryName & "`.Step_Date, `" & QueryName & "`.Salary, `"
& QueryName & "" _
, "`.Utilization, `" & QueryName & "`.`1198 BB_`, `" & QueryName
& "`.`KU/PCA`" & Chr(13) & "" & Chr(10) & "FROM `I:\CONSOLIDATION
UNIT\ACCESS DATABASE\Members Salary Forecast`.`" & QueryName & "` " _
, "`" & QueryName & "`" & Chr(13) & "" & Chr(10) &
strFilterCriteria & Chr(13) & "" & Chr(10))
.Name = "Query from MS Access Database_3"



.FieldNames = False
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.Refresh BackgroundQuery:=False
End With

Exit Sub


ERRORHANDLING:
If Err.Number = 1004 Then
Resume Next
Else: MsgBox "An error of type " & Err.Number & " has occured." &
vbLf & "Error: & " & Err.Description
End If
Exit Sub

End Sub



Thanks,
Carmen
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Start Excel in Text Import Wizard for data import rlelvis Setting up and Configuration of Excel 0 July 10th 08 08:40 PM
Excel Row Limitation - Import External Data Avadivelan TCS Excel Worksheet Functions 5 September 13th 06 04:53 PM
PLEASE!! How can I un-grey the 'Data-Import External Data-Import Data' option ??? kirkm[_6_] Excel Programming 13 August 8th 06 10:01 AM
Data Validation Limitation r wilcox Excel Programming 0 February 8th 06 10:24 PM
Import wizard limitation Sirocco Excel Discussion (Misc queries) 1 June 23rd 05 02:06 AM


All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"