Zdravím, potřebuji poradit s nefunkčním makrem, které má do pole načíst data z databáze MS Access. Načte se pouze jeden záznam a pak skončí chybou. chyba je popsaná v programu.
Hello, I need help with dysfunctional macro. I need read data from table to array, but it not works. Macro read only one record, after that stop with error. Error is described on the code
Sub NacteniPolotovary()
Dim db As Object
Dim swRecord As Recordset
Dim intArraySize As Integer 'The size of your array
Dim iCounter As Integer 'Index of the array
Set db = OpenDatabase("C:\Data\camaxis.accdb")
Set swRecord = db.OpenRecordset("SWx_Polotovary", dbReadOnly)
If Not swRecord.EOF Then
swRecord.MoveFirst
intArraySize = swRecord.RecordCount - 1 'swRecord.RecordCount This instruction has only 1 record, but table in MS Access has many records
iCounter = 0
ReDim PoleDatabaze_polotovaru(intArraySize, 6)
Do Until swRecord.EOF
PoleDatabaze_polotovaru(iCounter, 0) = swRecord.Fields("ProductID")
PoleDatabaze_polotovaru(iCounter, 1) = swRecord.Fields("DruhPolotovaru")
PoleDatabaze_polotovaru(iCounter, 2) = swRecord.Fields("Rozmer1")
PoleDatabaze_polotovaru(iCounter, 3) = swRecord.Fields("Rozmer2")
PoleDatabaze_polotovaru(iCounter, 4) = swRecord.Fields("Rozmer3")
PoleDatabaze_polotovaru(iCounter, 5) = swRecord.Fields("Norma")
PoleDatabaze_polotovaru(iCounter, 6) = swRecord.Fields("Material")
iCounter = iCounter + 1
swRecord.MoveNext 'Run-time error 424: Object required
Loop
End If
swRecord.Close
db.Close
Set swRecord = Nothing
Set db = Nothing
Děkuji
Thanks
SolidworksApi macros