Hi,
Please help,
I'm having a problem with the code below.
Its supposed to take a select few cells data from the excel front end submission form and the input it one piece at a time into the relevent columns of an access db.
In the line .addnew its giving me runtime error 3251 application defined or object
defined error
Any ideas?
Please help,
I'm having a problem with the code below.
Its supposed to take a select few cells data from the excel front end submission form and the input it one piece at a time into the relevent columns of an access db.
In the line .addnew its giving me runtime error 3251 application defined or object
defined error
Any ideas?
Code:
Sub Send2Access2()
Dim sNWind As String
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
'Open Connection'
sNWind = _
"[URL="file://\\W2K6082\common\SHARED\ShiftSwap\Database2.accdb"]\\W2K6082\common\SHARED\ShiftSwap\Database2.accdb[/URL]"
conn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
sNWind & ";"
conn.CursorLocation = adUseClient
Set rs = conn.Execute("Shift_Swap", , adCmdTable)
With rs
rs.AddNew
.Fields("Date Submitted").Value = Trim(Cells(50, 1).Text)
.Fields("Agent Email").Value = Trim(Cells(50, 2).Text)
.Fields("Date Requested").Value = Trim(Cells(50, 3).Text)
.Fields("Payback Date 1").Value = Trim(Cells(50, 4).Text)
.Fields("Payback Date 2").Value = Trim(Cells(50, 5).Text)
.Fields("Shift start").Value = Trim(Cells(50, 6).Text)
.Fields("Shift end").Value = Trim(Cells(50, 7).Text)
.Fields("RDO").Value = Trim(Cells(50, 8).Text)
.Fields("Call Type").Value = Trim(Cells(50, 9).Text)
' add more fields if necessary...
.Update ' stores the new record
End With
rs.Close
conn.Close
End Sub