Hello everyone,
I am new to this forum and MSAccess but I would like to ask you some help in understanding what I am missing in my code.
I have designed a form with unbound controls, in order to know exactly which messages/actions are done and when. So I have this button to save the data stored in the form in the designed table. In such a table I have a field, called "CausaRicovero", which is set to gather its allowed data from an other table and the field's lookup is set as combobox (more choices are allowed). Now, when in VBA I am trying to initialize the newly created record with "default" values, this field returns a run-time error 64224: "Method 'Collect' of object 'Recordset2' failed" . The code is as follows:
Code:
Dim Records As Recordset
If RecordNum = DCount("[Codice]", "DB Accoglienza") + 1 Then
Set Records = CurrentDb.OpenRecordset("DB Accoglienza")
Records.AddNew
Records![Codice] = 5555
Records![NomeSpecie] = "Piccione"
Records![DataAmmissione] = 11 / 11 / 1911
Records![CausaRicovero] = "Impatto"
Records![ProvinciaRitrovamento] = "Sconosciuta"
Records![TipologiaIDRitrovamento] = "Privato"
Records![NomeCognomeIDRitrovamento] = "Sconosciuto"
Records![ProvinciaIDRitrovamento] = "Sconosciuta"
Records![TipologiaIDConsegnatario] = "Privato"
Records![NomeCognomeIDConsegnatario] = "Sconosciuto"
Records![ProvinciaIDConsegnatario] = "Sconosciuta"
Records.Update
Records.Close
End If
I do not understand why I get this error, because other fields have similar design, although as listbox and not combobox.
Thanks in advance,
Aldo