here's a weird challenge guys....
is MS Access overwhelmed with data?
my code below DO what I want it to do but when the records jump up to 2 weeks of data (like 500 records)...it does not do what I want it to do.
example below is the data in my table... I will traverse thru this table and insert "z" record in between distinct records... it works perfectly for a week data. I also notice, if I save the actual MSAccess database in a fast laptop, and run it it WORKS OK.... on a Centrino 1.6GHz laptop...it doesnt....
any advice guys! Thanks !!!
* original table
a
a
b
b
b
b
c
c
c
d
e
* outcome table I want
a
a
z
b
b
b
b
z
c
c
c
z
d
z
e
z
and here's what it looks like when there's like 2000 of data
a
a
b <------there's should be a "z" before b. on debug window it showed it execute the code...
b
b
b
z <--------- on the debug window it does what I want it to do but final table does not match
c
below is my code:
Private Sub traverseMYOBNow()
' this method below will traverse the MYOBNow table
' and each unique record will do a query and
' loop thru this query and INSERT into MYOBFinal table
' then create a textfile based on MYOBFinal table then import to MYOB
CurrentDb.Execute "DELETE * FROM MYOBFINAL"
Dim strS, strSS, invNum As String
invNum = Me.txtInvNum.Value
Dim xa As DAO.Database, rxa As DAO.Recordset
Dim xa1 As DAO.Database, rxa1 As DAO.Recordset
strS = "SELECT * FROM MYOBNOW"
strSS = "SELECT DISTINCT MYOBNOW.CompanyOrLastname FROM MYOBNOW;"
Set xa = CurrentDb
Set rxa = xa.OpenRecordset(strS)
Set xa1 = CurrentDb
Set rxa1 = xa.OpenRecordset(strSS)
Dim countMYOBTotal, ix As Integer
rxa.MoveLast 'takes the pointer to the end to give total number
rxa1.MoveLast 'takes the pointer to the end to give total number
countMYOBTotal = rxa1.RecordCount
MsgBox countMYOBTotal & " and tot of MYOBNow table is: " & rxa.RecordCount
rxa.MoveFirst ' move pointer to the first in the list
rxa1.MoveFirst ' move pointer to the first in the list
For ix = 1 To countMYOBTotal
Dim strS1, rxSqlInsert As String
Dim xb As DAO.Database, rxb As DAO.Recordset
Dim ixx, rxbCounter As Integer
strS = "SELECT * FROM MYOBNow WHERE CompanyOrLastname='" & rxa1.Fields("CompanyOrLastName").Value & "';"
rxa1.MoveNext
Debug.Print strS
Set xb = CurrentDb
Set rxb = xb.OpenRecordset(strS)
rxb.MoveLast
rxbCounter = rxb.RecordCount
rxb.MoveFirst
Debug.Print "ix = " & ix & " -----> " & rxbCounter
For ixx = 1 To rxbCounter
'Debug.Print " " & rxbCounter
rxSqlInsert = "INSERT INTO MYOBFinal(CompanyOrLastname,Description,ItemNumber, Quantity, Price,Total,Invoice,CustomerPO,IncTaxTotal,IncTaxPrice) "
rxSqlInsert = rxSqlInsert & "VALUES('" & Replace(rxb.Fields("CompanyOrLastname").Value, "'", "") & "','" & rxb.Fields("Description").Value & "','"
rxSqlInsert = rxSqlInsert & rxb.Fields("ItemNumber").Value & "','" & rxb.Fields("Quantity").Value & "','" & rxb.Fields("Price").Value & "','" & rxb.Fields("Total").Value & "','" & rxb.Fields("Invoice").Value & "','" & rxb.Fields("CustomerPO").Value & "','" & rxb.Fields("IncTaxTotal").Value & "','" & rxb.Fields("IncTaxPrice").Value & " ');"
CurrentDb.Execute rxSqlInsert
Debug.Print "insert data..."
rxa.MoveNext
rxb.MoveNext
'ix = ix + 1
Next ixx
'z values
CurrentDb.Execute "Insert Into MYOBFinal(CompanyOrLastname) Values('z')" & ";"
Debug.Print "z..."
'PauseApp 1
'rxa.MoveNext
Next ix
Debug.Print ix & " --- end --- "
rxa.Close
rxb.Close
End Sub
OR is it time for me to move away from MSAccess?
any advice/ideas?
Thanks in advice guys!!!

is MS Access overwhelmed with data?
my code below DO what I want it to do but when the records jump up to 2 weeks of data (like 500 records)...it does not do what I want it to do.
example below is the data in my table... I will traverse thru this table and insert "z" record in between distinct records... it works perfectly for a week data. I also notice, if I save the actual MSAccess database in a fast laptop, and run it it WORKS OK.... on a Centrino 1.6GHz laptop...it doesnt....
any advice guys! Thanks !!!

* original table
a
a
b
b
b
b
c
c
c
d
e
* outcome table I want
a
a
z
b
b
b
b
z
c
c
c
z
d
z
e
z
and here's what it looks like when there's like 2000 of data
a
a
b <------there's should be a "z" before b. on debug window it showed it execute the code...
b
b
b
z <--------- on the debug window it does what I want it to do but final table does not match
c
below is my code:
Private Sub traverseMYOBNow()
' this method below will traverse the MYOBNow table
' and each unique record will do a query and
' loop thru this query and INSERT into MYOBFinal table
' then create a textfile based on MYOBFinal table then import to MYOB
CurrentDb.Execute "DELETE * FROM MYOBFINAL"
Dim strS, strSS, invNum As String
invNum = Me.txtInvNum.Value
Dim xa As DAO.Database, rxa As DAO.Recordset
Dim xa1 As DAO.Database, rxa1 As DAO.Recordset
strS = "SELECT * FROM MYOBNOW"
strSS = "SELECT DISTINCT MYOBNOW.CompanyOrLastname FROM MYOBNOW;"
Set xa = CurrentDb
Set rxa = xa.OpenRecordset(strS)
Set xa1 = CurrentDb
Set rxa1 = xa.OpenRecordset(strSS)
Dim countMYOBTotal, ix As Integer
rxa.MoveLast 'takes the pointer to the end to give total number
rxa1.MoveLast 'takes the pointer to the end to give total number
countMYOBTotal = rxa1.RecordCount
MsgBox countMYOBTotal & " and tot of MYOBNow table is: " & rxa.RecordCount
rxa.MoveFirst ' move pointer to the first in the list
rxa1.MoveFirst ' move pointer to the first in the list
For ix = 1 To countMYOBTotal
Dim strS1, rxSqlInsert As String
Dim xb As DAO.Database, rxb As DAO.Recordset
Dim ixx, rxbCounter As Integer
strS = "SELECT * FROM MYOBNow WHERE CompanyOrLastname='" & rxa1.Fields("CompanyOrLastName").Value & "';"
rxa1.MoveNext
Debug.Print strS
Set xb = CurrentDb
Set rxb = xb.OpenRecordset(strS)
rxb.MoveLast
rxbCounter = rxb.RecordCount
rxb.MoveFirst
Debug.Print "ix = " & ix & " -----> " & rxbCounter
For ixx = 1 To rxbCounter
'Debug.Print " " & rxbCounter
rxSqlInsert = "INSERT INTO MYOBFinal(CompanyOrLastname,Description,ItemNumber, Quantity, Price,Total,Invoice,CustomerPO,IncTaxTotal,IncTaxPrice) "
rxSqlInsert = rxSqlInsert & "VALUES('" & Replace(rxb.Fields("CompanyOrLastname").Value, "'", "") & "','" & rxb.Fields("Description").Value & "','"
rxSqlInsert = rxSqlInsert & rxb.Fields("ItemNumber").Value & "','" & rxb.Fields("Quantity").Value & "','" & rxb.Fields("Price").Value & "','" & rxb.Fields("Total").Value & "','" & rxb.Fields("Invoice").Value & "','" & rxb.Fields("CustomerPO").Value & "','" & rxb.Fields("IncTaxTotal").Value & "','" & rxb.Fields("IncTaxPrice").Value & " ');"
CurrentDb.Execute rxSqlInsert
Debug.Print "insert data..."
rxa.MoveNext
rxb.MoveNext
'ix = ix + 1
Next ixx
'z values
CurrentDb.Execute "Insert Into MYOBFinal(CompanyOrLastname) Values('z')" & ";"
Debug.Print "z..."
'PauseApp 1
'rxa.MoveNext
Next ix
Debug.Print ix & " --- end --- "
rxa.Close
rxb.Close
End Sub
OR is it time for me to move away from MSAccess?
any advice/ideas?
Thanks in advice guys!!!


Last edited: