timhans
Programmer
- Jun 24, 2009
- 75
Good morning, Trying ADO Cmd.Execute for first time, getting error msg run time error '-2147217833(80040e57)' Field to small to accept the amount of data, but runs in GUI as well as Docmd.Run SQL Attempting to update table with SQL statement here is the code I am using, any thoughts, comments or insight in to what I am doing wrong is greatly appreciated.
Private Sub btnRun_DblClick(Cancel As Integer)
Dim Cmd As ADODB.Command
Dim iSQL As String
Dim recs As Long
Set Cmd = New ADODB.Command
iSQL = "INSERT INTO tblCustomersFinished ( CustomerID, FirstName, LastName, Address, Apt, City, State, Phone, Zip, Contact, Physician, DOB, Model, SerialNumber, Insurance, Diagnosis)" & _
"SELECT CustomerID, FirstName, LastName, Address, Apt, City, State, Phone, Zip, Contact, Physician, DOB, Model, SerialNumber, Insurance, Diagnosis FROM " & Me.txtfromz.Value & ""
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = CurrentProject.Connection
Cmd.CommandText = iSQL
Cmd.CommandType = adCmdText
Cmd.Execute RecordsAffected:=recs,options:=adExecuteNoRecords 'this is hilighted in debug mode
Set Cmd = Nothing
Exit Sub
ConnectionError:
MsgBox "There was an Error Connecting to the DataBase." & Chr(13) _
& Err.Number & ", " & Err.Description
End Sub
Private Sub btnRun_DblClick(Cancel As Integer)
Dim Cmd As ADODB.Command
Dim iSQL As String
Dim recs As Long
Set Cmd = New ADODB.Command
iSQL = "INSERT INTO tblCustomersFinished ( CustomerID, FirstName, LastName, Address, Apt, City, State, Phone, Zip, Contact, Physician, DOB, Model, SerialNumber, Insurance, Diagnosis)" & _
"SELECT CustomerID, FirstName, LastName, Address, Apt, City, State, Phone, Zip, Contact, Physician, DOB, Model, SerialNumber, Insurance, Diagnosis FROM " & Me.txtfromz.Value & ""
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = CurrentProject.Connection
Cmd.CommandText = iSQL
Cmd.CommandType = adCmdText
Cmd.Execute RecordsAffected:=recs,options:=adExecuteNoRecords 'this is hilighted in debug mode
Set Cmd = Nothing
Exit Sub
ConnectionError:
MsgBox "There was an Error Connecting to the DataBase." & Chr(13) _
& Err.Number & ", " & Err.Description
End Sub