Hi all,
I have created a form to save my recipes to my table Called Table2.
Every time I click on the save button I get the following error.
User-Defined type Not Defined.
I am filling out all my text boxes and trying to save them to my table.
Any help would be appreciated, I'm not quite sure where I have gone wrong.
Below is the code I am using,
Code:
Option Compare Database
Option Explicit
Private Sub CmdSave_Click()
'When a User is finished adding a Recipe, and presses Save.
If Me.txtName = "" Or Me.txtIngredients = "" Or Me.txtMethod = "" Or Me.txtNotes = "" Or Me.txtNutritional = "" Then
MsgBox "Please make sure make sure all fields are filled in place a full stop in a field if no info required", vbInformation
Exit Sub
End If
Dim cmd As Command
Set cmd = New Command
'Query that inserts a new Recipe into the Recipe Table. Users will not be able to access the DB if they are not in the User Table.
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = "INSERT INTO Table2 (Category, RcpName, rcpIngredients, rcpMethod, Nutritional, PerServe, rcpNotes, Image) " _
& "VALUES('" & Me.txtCategory & "', '" & Me.txtName & "', '" & Me.txtIngredients & "', '" & Me.txtMethod & "', '" & Me.txtNotes & "', '" & Me.txtNutritional & "','" & Me.txtCount & "', '" & Me.txtImageName & "')"
cmd.Execute
Set cmd = Nothing
Me.Refresh
End Sub