S
SME
I would like to insert some values into a table, but I'm
having trouble adding quotes (") around the string value.
Would I also need to add hash marks (#) around the date
entry?
Also, the text box containing the date is formated to
accept a short date (mm/dd/yyyy) ... and an error is
displayed if a date is entered incorrectly, but I would
like to catch this and present a friendlier error
message. What would be the best method to do that?
And last question What is the difference
between 'DoCmd.RunSQL strSQL' and 'CurrentDb.Execute
strSQL, dbFailOnError'
Many thanks in advance for your time.
****** Code used to insert values
Private Sub btnSave_Click()
Dim newDate As Date
Dim newEntry As String
Dim newReferral As Boolean
Dim internNumber As Integer
Dim strSQL As String
'check for null values here
internNumber = Me.internID
newDate = Me.txtDate
newEntry = Me.txtEntry
newReferral = Me.chkReferral
strSQL = "INSERT INTO tblInternsContactLog (internID,
contactLog_date, contactLog_entry,
contactLog_isreferral) "
strSQL = strSQL & "VALUES (" & internnumber & ", " &
newDate & ", " & newEntry & ", " & newReferral & " )"
' DoCmd.RunSQL strSQL
' CurrentDb.Execute strSQL, dbFailOnError
having trouble adding quotes (") around the string value.
Would I also need to add hash marks (#) around the date
entry?
Also, the text box containing the date is formated to
accept a short date (mm/dd/yyyy) ... and an error is
displayed if a date is entered incorrectly, but I would
like to catch this and present a friendlier error
message. What would be the best method to do that?
And last question What is the difference
between 'DoCmd.RunSQL strSQL' and 'CurrentDb.Execute
strSQL, dbFailOnError'
Many thanks in advance for your time.
****** Code used to insert values
Private Sub btnSave_Click()
Dim newDate As Date
Dim newEntry As String
Dim newReferral As Boolean
Dim internNumber As Integer
Dim strSQL As String
'check for null values here
internNumber = Me.internID
newDate = Me.txtDate
newEntry = Me.txtEntry
newReferral = Me.chkReferral
strSQL = "INSERT INTO tblInternsContactLog (internID,
contactLog_date, contactLog_entry,
contactLog_isreferral) "
strSQL = strSQL & "VALUES (" & internnumber & ", " &
newDate & ", " & newEntry & ", " & newReferral & " )"
' DoCmd.RunSQL strSQL
' CurrentDb.Execute strSQL, dbFailOnError