From a form fields in MS Access I'm attempting to move the values to a SQL Server table.
Thanks
When I execute the VBA code I receive the following message of "Syntax error in INSERT INTO statement".
I can take the code from the Immediate display and copy it to the SQL Server New Query tab and execute it and it performs the command perfectly. What suggestions does anyone have as to what I'm performing incorrectly?
Private Sub btnSixClicksAdmittedPatientsByDates_Click()
On Error GoTo Err_btnSixClicksAdmittedPatientsByDates_Click
Dim Response As Integer
Dim dbs As DAO.Database
Dim rs As DAO.Recordset
Dim sqlstr As String
Dim objControl As Control
Set dbs = CurrentDb
sqlstr = "INSERT INTO [mcif].[dbo].[tblSixClicks_Report_Criteria] ([Rehab_SixClicks_Campus],[Rehab_SixClicks_Department]) " & _
"VALUES ('" & cboReportCampusSelection.Value & "','" & CBOReportDepartmentSelection.Value & "')"
Debug.Print sqlstr
DoCmd.SetWarnings False
DoCmd.RunSQL sqlstr
DoCmd.SetWarnings True
Immediate view that works in SQL Server:
INSERT INTO [mcif].[dbo].[tblSixClicks_Report_Criteria] ([Rehab_SixClicks_Campus],[Rehab_SixClicks_Department]) VALUES ('DMM','DML 3 EAST')