pedie
Well-known Member
- Joined
- Apr 28, 2010
- Messages
- 3,875
Hi, I am using Bill's code from ebook. I want to confirm and seek expert/expirienced users advice on how Excel and Access works.
Users updates information from excel using it as front end and access as Database to store all DATAS.
I want to make sure if 2 or more users updates at the same time from thier respective computer to database in network drive will there be any error? Do i have to do any special type of settings for this?
Please advice.
Thanks alot in advance.
Users updates information from excel using it as front end and access as Database to store all DATAS.
I want to make sure if 2 or more users updates at the same time from thier respective computer to database in network drive will there be any error? Do i have to do any special type of settings for this?
Please advice.
Thanks alot in advance.
Code:
[/FONT]
[FONT=Courier New]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
MyConn = ThisWorkbook.Path & Application.PathSeparator & "Transfers.mdb"
MyConn = "Driver=Microsoft Access Driver (*.mdb);DBQ=" & MyConn
' open the connection
Set cnn = New ADODB.Connection
With cnn
'.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
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