Hi guys
I posted earlier today for some help with INSERT Queries and thanks to the help of @Uncle Gizmo I managed to get it all good. However, I'm creating another form for inserting data, but this one doesn't seem to be working correctly. No errors are given but no change to the database? It's a bit peculiar anyway here's my code
The Function:
The Execution Code:
Thanks, Ryan
I posted earlier today for some help with INSERT Queries and thanks to the help of @Uncle Gizmo I managed to get it all good. However, I'm creating another form for inserting data, but this one doesn't seem to be working correctly. No errors are given but no change to the database? It's a bit peculiar anyway here's my code
The Function:
Code:
Private Function fAddRec(FirstName As String, LastName As String, HouseNumber As Integer, StreetName As String, City As String, PostCode As String, MobileNum As String, Email As String, CardNum As String, ExpiryDate As String, SecurityCode As Integer, Remarks As String)
'Add Text Delimiters - Chr(34) = "
FirstName = Chr(34) & FirstName & Chr(34)
LastName = Chr(34) & LastName & Chr(34)
StreetName = Chr(34) & StreetName & Chr(34)
City = Chr(34) & City & Chr(34)
PostCode = Chr(34) & PostCode & Chr(34)
MobileNum = Chr(34) & MobileNum & Chr(34)
Email = Chr(34) & Email & Chr(34)
CardNum = Chr(34) & CardNum & Chr(34)
Remarks = Chr(34) & Remarks & Chr(34)
'Add Date Delimiters - Chr(35) = #
ExpiryDate = Chr(35) & ExpiryDate & Chr(35)
Dim strSQL0 As String
Dim strSQL1 As String
Dim strSQL2 As String
strSQL1 = "INSERT INTO tblUserDetails(FirstName, LastName, HouseNumber, StreetName, City, PostCode, MobileNum, Email, CardNum, ExpiryDate, SecurityCode, Remarks) "
strSQL2 = "Values(" & FirstName & ", " & LastName & ", " & HouseNumber & ", " & StreetName & ", " & City & ", " & PostCode & ", " & MobileNum & ", " & Email & ", " & CardNum & ", " & ExpiryDate & ", " & SecurityCode & ", " & Remarks & ")"
strSQL0 = strSQL1 & strSQL2
CurrentDb.Execute strSQL0
End Function 'fAddRec
The Execution Code:
Code:
Private Sub btnCreate_Click()
SQLInsert = fAddRec(Me.txtForename, Me.txtSurname, Me.txtHouseNum, Me.txtStreet, Me.txtCity, Me.txtPostCode, Me.txtMobileNum, Me.txtEmail, Me.txtCardNum, Me.txtExpiry, Me.txtSecurity, Me.txtRemarks)
End Sub
Thanks, Ryan