Okay, the short version of the problem is this: I've got a fairly simple data entry form which I created using the creat form wizard and then customized on my own. It has a query passed to it from another form upon loading, and it appropriately shows the correct number of records for the query. I should then be able to either update or add any record from then on. However, whenever I try either to change any field of an existing record or add a new record, I always get the following error:
Run-time error '3421':
Data type conversion error.
Here is a copy of all of the code behind the form:
Option Compare Database
Private msReportName As String
Private Sub btnExit_Click()
Private Sub cmdBack_Click()
Form_wizUpdateTemplate.Move Me.WindowLeft, Me.WindowTop
Form_wizUpdateTemplate.Visible = True
Me.Visible = False
Public Property Get MyReportName() As String
MyReportName = msReportName
Public Property Let MyReportName(asVal As String)
msReportName = asVal
Private Sub Form_BeforeUpdate(Cancel As Integer)
<i> Form.Recordset.Update "ReportName", MyReportName</i>
The italicized line is where it dies at.
Here is something very important that I should mention: While this is ultimately a very simple data entry/edit form, there is one field for each row which I do *NOT* want the user to have to edit or even be able to see. This field contains the primary key which must be the same for each row in the dataset in the form. If this field is left blank, the program will not be able to retrieve the newly added row for each subsequent query. Unfortunately, the default is for this field to be left blank, and having it auto-populate by setting the "default value" in the table is insufficent because this value will change depending on the query which is passed to the form.
Anyway, I just thought I'd mention the above in case you were wondering why I didn't just leave it at what the wizard created.
Any ideas on how to fix this error?
I really appreciate the help!