Question : Insert Statement

I have created a form and want to insert the the values from the form into a table.

The code i sfailing at this line:

DBEngine(0)(0).Execute strSQL
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Private Sub cmdAddNewLocation_Click()

Dim strSQL As String
Dim stDocName As String
Dim stLinkCriteria As String

strSQL = "INSERT INTO [tblLocation] (txtLocation, cboCountyID, cboTownID, cboDivisionID, cboDivisionDistrictID, cboLocationTypeID, cboLocationStatusID, txtLAddress1, txtLAddress2, txtLAddress3, txtLTelephone, txtLFax, txtLEmail, txtLComments ) VALUES ("

strSQL = strSQL & Me!txtLocation & "', "
strSQL = strSQL & "'" & Me!cboCountyID & ", "
strSQL = strSQL & "'" & Me!cboTownID & ", "
strSQL = strSQL & "'" & Me!cboDivisionID & "', "
strSQL = strSQL & "'" & Me!cboDivisionDistrictID & "', "
strSQL = strSQL & "'" & Me!cboLocationTypeID & ", "
strSQL = strSQL & "'" & Me!cboLocationStatusID & ", "
strSQL = strSQL & "'" & Me!txtLAddress1 & "', "
strSQL = strSQL & "'" & Me!txtLAddress2 & "', "
strSQL = strSQL & "'" & Me!txtLAddress3 & "', "
strSQL = strSQL & "'" & Me!txtLTelephone & "', "
strSQL = strSQL & "'" & Me!txtLFax & "', "
strSQL = strSQL & "'" & Me!txtLEmail & "', "
strSQL = strSQL & Me!txtLComments & ");"

Debug.Print strSQL

DBEngine(0)(0).Execute strSQL

End Sub

Answer : Insert Statement


strSQL = strSQL & "'" & Me!txtLComments & "', );"

should be:

strSQL = strSQL & "'" & Me!txtLComments & "' )"
Random Solutions  
 
programming4us programming4us