I've declared my variables as follows:
Dim Outlets As Integer Dim Sides As String Dim Material As String Dim Brackets As String Dim Inlet As String Dim Vent As String Dim Outlet As String Dim IOVcode As String Dim ItemPrice As String
As well as the following in a module:
Global CODE As String Global ItemPrice As Integer
The bit of code that doesn't want to work is the following:
Private Sub cmdDatabase_Click() dataHeaders.Recordset.AddNew '<================= VB flags this up as the issue upon clicking debug dataHeaders.Recordset![Outlets] = Outlets dataHeaders.Recordset![Material] = Material dataHeaders.Recordset![Sides] = Sides dataHeaders.Recordset![Inlet] = Inlet dataHeaders.Recordset![Outlet] = Outlet dataHeaders.Recordset![Vent] = Vent dataHeaders.Recordset![Brackets] = Brackets dataHeaders.Recordset![Partcode] = CODE dataHeaders.Recordset![Approximate Cost] = ItemPrice dataHeaders.Recordset.Update MsgBox "Data Saved Successfully", vbOKOnly, "Partcode" cmdNew.Visible = True cmdSend.Visible = True cmdDatabase.Visible = False End Sub
Upon clicking cmdDatabase, VB returns the error:
Visual Basic said:
Object variable or With block variable not set.
When you click debug, as you can see in the code above, it highlights "dataHeaders.Recordset.AddNew" as the issue.
I hope you can help me as this error's got me tearing my hair out! I'll be more than happy to provide any additional information you require.
Regards, and thank you in advance,