[AccessD] Autonumber when?

Jim Dettman jimdettman at verizon.net
Wed Apr 6 09:38:29 CDT 2011


John,

  A little code cleanup:

Exit_mPLSLogin:
     On Error Resume Next
     Set rs = Nothing
     If Not (rs Is Nothing) Then rs.Close: Set rs = Nothing
     Exit Function

Should be:

Exit_mPLSLogin:
     On Error Resume Next

     If Not (rs Is Nothing) Then
       rs.Close
       Set rs = Nothing
     End If

     Exit Function

Jim.

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jwcolby
Sent: Wednesday, April 06, 2011 10:07 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Autonumber when?

Rusty,

The following is the actual code.

'
'Adds a record to the table saying that a specific user logged in at a
specific time
'
'*+ Private class functions
Private Function mPLSLogin(blnLogIn As Boolean)
Dim rs As DAO.Recordset
Dim db As DAO.Database

On Error GoTo Err_mPLSLogin

     Set db = dbDAOCurr
     Set rs = db.OpenRecordset("usystblPLSLog", dbOpenDynaset, dbSeeChanges)
     If mlngIDUser = 0 Then Exit Function
     With rs
         .AddNew
         !PLSL_IDPLSUSR = mlngIDUser
         !PLSL_FE = CurrentProject.Name
         !PLSL_Login = blnLogIn
         !PLSL_WorkstationID = CurrentMachineName()
         On Error Resume Next
         mlngLogID = !PLSL_ID
         .Update
         If Err Then
             mlngLogID = !PLSL_ID
         End If

         .Close
     End With

Exit_mPLSLogin:
     On Error Resume Next
     Set rs = Nothing
     If Not (rs Is Nothing) Then rs.Close: Set rs = Nothing
     Exit Function
Err_mPLSLogin:
     Select Case Err
     Case 0      '.insert Errors you wish to ignore here
         Resume Next
     Case Else   '.All other errors will trap
         Beep
         PLSLogErr Err.Number, Err.Description, Erl, cstrModule, "mPLSLogin"
         Resume Exit_mPLSLogin
     End Select
     Resume 0    '.FOR TROUBLESHOOTING
End Function


John W. Colby
www.ColbyConsulting.com

On 4/6/2011 9:47 AM, Rusty Hammond wrote:
> When you set your recordset are you using the dbSeeChanges option?
-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list