Results 1 to 6 of 6
  1. #1
    manicamaniac is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    13

    Exclamation Auto Complete Data

    Hi,

    I need some help developing a vba code to complete one field of one table.
    You can see the attached picture to have an idea of what I need.
    I need a code that reads when there's information and paste it to the records below until the next one with inserted data (non-blank).



    So it should copy the first, paste to the following blank cells, and copy again when another number at "Descrição" field is shown, and the process repeats..


    Thanks a lot friends!
    Last edited by manicamaniac; 09-14-2010 at 03:32 PM.

  2. #2
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what is being copied? you already know the criteria for insertion. that's the presence of a value in the first column. but what are you throwing into the other column? an array? value from excel? incremented values based on another criteria located elsewhere? before you can write the function, you have to know that portion of the equation.

  3. #3
    manicamaniac is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    13
    I just need to complete the first column.
    I need to copy the first number to the blank cells below.
    When it reaches another value, it should copy the new value and paste at the blank cells below...

  4. #4
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by manicamaniac View Post
    I just need to complete the first column.
    I need to copy the first number to the blank cells below.
    When it reaches another value, it should copy the new value and paste at the blank cells below...
    I don't know if there is a query that can do it, but the easiest way may be just to run the code below. PLEASE make sure to run the compiler BEFORE trying this code. It is not tested. thanks.

    Code:
    function pTbl()
    
    dim db as dao.database
    dim rs as dao.recordset
    dim sNum as long
    
    set db = currentdb
    set rs = db.openrecordset("table name here")
    
    with rs
    
       .movelast
       .movefirst
    
          while not .eof
             if not isnull(!Column1Name) or _
                     len(!Column1Name) < 1 or _
                     !Column1Name = "" then
                sNum = !Column1Name
                   .movenext
    
            else
               .edit
                  !Column1Name = sNum
               .update
                     .movenext
            end if
         wend
    
                  .close
               db.close
    
    end with
    
    set rs = nothing
    set db = nothing
    
    end function

  5. #5
    manicamaniac is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2010
    Posts
    13
    Thanks friend!
    It worked just fine =)

  6. #6
    ajetrumpet is offline Banned
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by manicamaniac View Post
    Thanks friend!
    It worked just fine =)
    good luck with it.

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

Similar Threads

  1. New to access, looking for steps to complete
    By iamyourdemize in forum Access
    Replies: 1
    Last Post: 05-21-2010, 02:19 PM
  2. Replies: 6
    Last Post: 04-14-2010, 11:03 AM
  3. Some advise for a complete novice...!
    By 450nick in forum Access
    Replies: 1
    Last Post: 09-11-2009, 02:23 AM
  4. Auto Populate Data from Main Form
    By billiejean in forum Forms
    Replies: 0
    Last Post: 08-05-2009, 08:08 AM
  5. Complete, noob help with where to start?
    By tragik in forum Queries
    Replies: 2
    Last Post: 06-29-2009, 09:20 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