Class Tovar:

Public Code As Integer Public Number As String Public manufacturer As String Public tovar_type As String Public group As String Public comment As String 

Main code:

 Sub main() Dim mdb: Set mdb = Access.CurrentDb Dim sSQL As String: sSQL = "SELECT * FROM [SOTRAS]" Dim rst As Recordset: Set rst = mdb.OpenRecordset(sSQL) Dim item As Tovar Do While Not rst.EOF Set item = New Tovar item.Code = rst.Fields("Êîä") item.manufacturer = rst.Fields("Ïðîèçâîäèòåëü") item.Number = rst.Fields("Íîìåð") item.tovar_type = rst.Fields("Òèï") add_tovar (item) rst.NextRecordset Loop rst.Close: Set rst = Nothing mdb.Close: Set mdb = Nothing End Sub Sub add_tovar(a As Tovar) ..... End sub 

When you run the line add_tovar (item) crashes:

Object doesn't support this property or method (Error 438)

    3 answers 3

    Understood. Correctly use the following lines:

     Call add_tovar(item) rst.MoveNext 

      If you call a procedure without a return value, you can write a call in the code in two ways:
      Call add_tovar(item)
      or
      add_tovar item

        define the type at the very beginning of the module

        Type tovar

        Price as Single

        Name as String

        TypeTovar as Byte

        Manufact as string

        End type

        'then

        Sub main () Dim mdb: Set mdb = Access.CurrentDb Dim sSQL As String: sSQL = "SELECT * FROM [SOTRAS]" Dim rst As Recordset: Set rst = mdb. OpenRecordset (sSQL) Dim item As Tovar

        ' And everything else