pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Adding records to Database getting following error...
Getting error message exact as below
Actual Code: error on BLUE line below.
I would really appriciate any help. Just stucked just dont know how to proceed...just same error already asked by someone too but doesnt solve me problem.
The code is from Bill's Latest book i guess .
Thanks again
Getting error message exact as below
Code:
[FONT=Courier New]'-2147467259 (80004005)': [Microsoft] [/FONT]
[FONT=Courier New][ODBC Microsoft Access driver] not a valid password [/FONT]
Actual Code: error on BLUE line below.
I would really appriciate any help. Just stucked just dont know how to proceed...just same error already asked by someone too but doesnt solve me problem.
Rich (BB code):
Sub CallAddTransfer()
' Used to call the code from page 480
Dim WS As Worksheet
Dim Qty As Integer
Set WS = Worksheets("AddRecords")
FinalRow = WS.Cells(Rows.Count, 1).End(xlUp).Row
Ctr = 0
For i = 7 To FinalRow
Style = Cells(i, 1).Value
FromStore = Cells(i, 2).Value
ToStore = Cells(i, 3).Value
Qty = Cells(i, 4).Value
Ctr = Ctr + 1
Application.StatusBar = "Adding Record " & Ctr
AddTransfer Style, FromStore, ToStore, Qty
Next i
Application.StatusBar = False
MsgBox Ctr & " records added."
End Sub
Sub AddTransfer(Style As Variant, FromStore As Variant, ToStore As Variant, Qty As Integer)
' Page 480
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim pwd As String
MyConn = ThisWorkbook.Path & Application.PathSeparator & "Transfers.mdb"
MyConn = "Driver=Microsoft Access Driver (*.mdb);DBQ=" & MyConn
pwd = "mypass"
' open the connection
Set cnn = New ADODB.Connection
With cnn
'.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn, mypass
End With
' Define the Recordset
Set rst = New ADODB.Recordset
rst.CursorLocation = adUseServer
' open the table
rst.Open Source:="tblTransfer", _
ActiveConnection:=cnn, _
CursorType:=adOpenDynamic, _
LockType:=adLockOptimistic, _
Options:=adCmdTable
' Add a record
rst.AddNew
' Set up the values for the fields. The first four fields
' are passed from the calling userform. The date field
' is filled with the current date.
rst("Style") = Style
rst("FromStore") = FromStore
rst("ToStore") = ToStore
rst("Qty") = Qty
rst("tDate") = Date
rst("Sent") = False
rst("Receive") = False
' Write the values to this record
rst.Update
' Close
rst.Close
cnn.Close
End Sub
Thanks again
Last edited: