Hi
Using Access 2007, I have a form created that uses a combo box to select records from an underlying table. I want the user to be able to create a new record with absolutely no pre-set data in it to allow them to key in the new data themselves. I am really stuck as to how to do this.
I have added a cmd button to the form and have tried using the following code that I picked up from here:
When I execute, it tells me run-time error 3058; Index or primary key cannot contain a Null value.
Registration is my primary key.
Can anyone help please?
Using Access 2007, I have a form created that uses a combo box to select records from an underlying table. I want the user to be able to create a new record with absolutely no pre-set data in it to allow them to key in the new data themselves. I am really stuck as to how to do this.
I have added a cmd button to the form and have tried using the following code that I picked up from here:
Code:
Private Sub cmdNew_Click()
Dim dbsVehicle_Sales As DAO.Database
Dim rsttblAECarAuctionDisposals As DAO.Recordset
Set dbsVehicle_Sales = CurrentDb
Set rsttblAECarAuctionDisposals = dbsVehicle_Sales.OpenRecordset("tblAECarAuctionDisposals", dbOpenDynaset)
With rsttblAECarAuctionDisposals
.AddNew
![Registration] = strStringVariable
![Tag] = strStringVariable
![VAT Status] = strStringVariable
![Vehicle Description] = strStringVariable
![Buyer] = strStringVariable
![Date Sold] = dteDateVariable
![Sale Price (Gross)] = curCurrencyVariable
![VAT] = curCurrencyVariable
![Net Proceeds] = curCurrencyVariable
![Mileage] = lngLongVariable
![Year/Letter] = strStringVariable
.Update
End With
End Sub
When I execute, it tells me run-time error 3058; Index or primary key cannot contain a Null value.
Registration is my primary key.
Can anyone help please?
Comment