Results 1 to 5 of 5
  1. #1
    mks123's Avatar
    mks123 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    33

    Lock Type and Cursor Type - To update and to extract data from Access to Excel

    Hi All,

    I have developed one Tracker ( in MS Excel) which will be using by around 40 people at same time basically only for to add records in Table (MS Access Database). so which is the best Cursor Type and Lock Type.



    I'm using ADO.


    I think C.T. "adopenkeyset" and L.T "adLockPessimistic" would be right type, but still not sure ?


    Subject - Lock Type and Cursor Type - To update and to extract data from Access to Excel

    Thanks!
    Regards,
    Mks

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    same time basically only for to add records in Table
    if they are only adding data, I wouldn't think locking matters since it only applies if you are changing an existing record

  3. #3
    mks123's Avatar
    mks123 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    33
    I'm using below code to add record to table named "tblSystemData", at same time around 30 people would be using it.

    this works when single user use it.

    trying to hard to figure it out, what is wrong with this code.

    Code:
    Option Explicit
    Public Lpdata As ADODB.Recordset
    Public Lpcon As ADODB.Connection
    Public opath, ofilename, oextension As String
    Public Accesstring As String
    Public Const ReadOnlyDB = "PROD_Tracker Database"
    Public Const DefultDB = "PROD_Tracker Database_be"
    
    
    
    
    Sub Connection_data()
    
    
    
    
    Dim opath As String
    opath = Sheet2.Cells(1, "G").value
    
    
    On Error GoTo ExitPnt
    ofilename = opath & DefultDB
    oextension = ofilename & ".accdb"
    
    
    Set Lpcon = New ADODB.Connection
    
    
    
    
    Accesstring = "Provider=Microsoft.ACE.OLEDB.12.0;" _
                  & "Data Source=" & oextension & ";" _
                  & "Persist Security Info = false"
    Lpcon.ConnectionString = Accesstring
    Lpcon.Open
    
    
    Exit Sub
    
    
    ExitPnt:
    
    
    MsgBox Err.Number & "---" & Err.Description
    
    
    MsgBox "Please Contact Admin"
    'Call JustStopTimer
    ThisWorkbook.Close False
    
    
    End Sub
    
    
    
    
    
    
    Sub RetriveData(oSysStatus As String)
    Set Lpdata = New ADODB.Recordset
    
    
    Call Connection_data
    On Error GoTo Exitpoint
    With Lpdata
        .ActiveConnection = Lpcon
        .Source = "tblSystemData"
        .CursorType = adOpenKeyset
        .LockType = adLockPessimistic
        .CursorLocation = adUseClient
        .Open
    End With
    
    
    With Lpdata
      .AddNew
          .Fields("User") = Environ("UserName")
          .Fields("USerName") = Application.UserName
          .Fields("Date") = Date
          .Fields("Time") = Time
          .Fields("FullTimeInfo") = Now()
          .Fields("Remark") = oSysStatus                                    '"Mukesh"
          .Fields("TimeID") = TimeID
          .Fields("ComputerName") = VBA.Environ("ComputerName")
         ' .Fields("ClientName") = VBA.Environ("ClientName")
      .Update
    
    
     End With
    
    
    Lpdata.Close
    Lpcon.Close
    Set Lpdata = Nothing
    Set Lpcon = Nothing
    
    
    Exit Sub
    Exitpoint:
    
    
    MsgBox Err.Number & "---" & Err.Description
    'Call JustStopTimer
    MsgBox "Please Contact Admin"
    ThisWorkbook.Close False
    
    
    End Sub

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    Not sure,

    date and time are reserved words in access that might be causing some confusion.

    You say it works with one user, what does that mean? many connected to the db and one can update and the others can't? in which case it is a permissions issue

  5. #5
    mks123's Avatar
    mks123 is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2014
    Posts
    33
    let me explain in detail, excel macro(with userform) and access database saved on Shared Drive.currently around 30 people could use that excel macro same time to add new record in Access database in same table.

    what happen when I use alone everything works fine and smooth, but the moment other user opens the excel macro and try to add new record to database system through the error "2147467259 Operation must use an updateable query".

    what I' m try to say at same time only one user can update Database, If other use try to access both get error.


    Regards,
    Mukesh Y

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update access Forms and data type
    By Amen in forum Access
    Replies: 4
    Last Post: 09-25-2013, 05:49 PM
  2. Replies: 2
    Last Post: 02-27-2013, 10:40 AM
  3. Replies: 5
    Last Post: 01-09-2012, 05:55 PM
  4. Import to Excel from Access column of LOOKUP data type
    By Derek in forum Import/Export Data
    Replies: 1
    Last Post: 12-06-2010, 06:27 PM
  5. Replies: 2
    Last Post: 03-18-2010, 08:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums