Results 1 to 2 of 2
  1. #1
    NicksMovement is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Aug 2017
    Posts
    3

    Update blank records to last record number + 1

    Hey all, I'd like to update blank records in a table to the next greatest value. The PONumber will be populated in a Form but the user will not have the option to update the job number. Eventually, I'd like to put a button on the form (or somewhere relevant) along the lines of "Update Job Numbers". I'm having a bit of trouble constructing the query that updates the blank cells as shown below. I'm not too versed yet in a lot of the SQL language or VBA so any insight here will likely be beneficial.



    TestID POnumber Jobnumber
    1 1856 1600
    2 1857 1601
    3 1858 1602
    4 1859 1603
    5 1860 1604
    6 1861 1605
    7 1862
    8 1863
    9 1864
    10 1865

    As in my last request, can someone point me in the right direction or direct me to a previous thread where this was solved? Thank you all for you time

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    put code in a module then run it.

    Code:
    Public Sub IncrJob()
    Dim rst
    Dim sSql As String
    
    
    sSql = "select * from table order by [Testid]"
    Set rst = CurrentDb.OpenRecordset(sSql)
    With rst
       While Not .EOF
            If Not IsNull(.Fields("jobNumber")) Then
                vJob = .Fields("jobNumber").value
            Else
                vJob = vJob + 1
                .Edit
                  .Fields("jobNumber").value = vJob
                .Update
            End If
            
            .MoveNext
       Wend
    End With
    Set rst = Nothing
    End Sub

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

Similar Threads

  1. Replies: 4
    Last Post: 08-22-2017, 02:47 PM
  2. Replies: 12
    Last Post: 08-19-2016, 11:23 AM
  3. Replies: 4
    Last Post: 12-04-2015, 09:08 PM
  4. Replies: 4
    Last Post: 01-12-2015, 12:16 PM
  5. Replies: 2
    Last Post: 03-07-2014, 09:40 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