I have a form that I am creating for data entry and on that form there is a combo box where a user can add multiple items that are added to another table and then display in a list box (see the attachment for a screenshot.)
The code behind the "Add" button is:
This works just fine as long as you are adding a Attestation to an existing record. However, when you create a new record and try to add an Attestation, it throws up an error message: "No current record"
I think what's going on is that the main record is not getting saved and so there is no AuditNumber in the main table that corresponds to the AuditNumber that it's trying to add to the Attestation table.
How can I fix this?
The code behind the "Add" button is:
Code:
Me.Refresh
Dim Adbs As DAO.Database
Dim Arst As DAO.Recordset
Dim Aqd As DAO.QueryDef
Set Adbs = CurrentDb
Set Aqd = Adbs.QueryDefs!qryAddAttest
Set Arst = Aqd.OpenRecordset
Arst.AddNew
Arst!AuditNumber = Me.AuditNumber
Arst!AttestNumber = Me.AttestChoice
Arst.Update
Set Arst = Nothing
Set Aqd = Nothing
Me.AttestList.Requery
This works just fine as long as you are adding a Attestation to an existing record. However, when you create a new record and try to add an Attestation, it throws up an error message: "No current record"
I think what's going on is that the main record is not getting saved and so there is no AuditNumber in the main table that corresponds to the AuditNumber that it's trying to add to the Attestation table.
How can I fix this?