Results 1 to 2 of 2
  1. #1
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383

    Function Need s To Update Table

    I have a module that works but it also needs to update the table so that the next record will advance. Here is the code for the module:
    Table that needs to get update after this code runs is EventCounterTable with field NextCustomEventIDCounter getting updated.
    The code on my form I am using to update the next counter is: It does not advance the counter in the table though.

    Me.newid = GetNextID("EventCounterTable", "NextCustomEventIDCounter") 'Purpose: Increment newid as a counter.

    (Module)

    Public Function GetNextID(tblName As String, idfieldName As String) As Long
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim lngOut As Long


    lngOut = 0


    Set db = CurrentDb()


    Set rst = db.OpenRecordset("select Max([" & idfieldName & "]) as ID from [" & tblName & "]", dbOpenSnapshot)


    If rst.RecordCount > 0 Then
    lngOut = rst!id + 1
    End If
    rst.Close


    GetNextID = lngOut

  2. #2
    burrina's Avatar
    burrina is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Location
    Freeport,Texas
    Posts
    1,383
    NO Longer needed. Thanks!

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

Similar Threads

  1. After Update Event with power function
    By Fish218 in forum Forms
    Replies: 5
    Last Post: 01-15-2013, 01:29 PM
  2. Update Function Like DLookup
    By EddieN1 in forum Access
    Replies: 1
    Last Post: 01-04-2013, 12:31 PM
  3. Replies: 1
    Last Post: 02-08-2012, 04:50 PM
  4. Update with left function
    By yerromnitsuj in forum Access
    Replies: 3
    Last Post: 01-09-2012, 03:41 PM
  5. running a function after update
    By jamin14 in forum Programming
    Replies: 9
    Last Post: 04-06-2010, 09:40 AM

Tags for this Thread

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