Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

edit a field using VBA...

Posted on 2006-11-24
5
Medium Priority
?
880 Views
Last Modified: 2008-03-01
Hi! I have a table like this...

ID      NUM      NGROUP      
1                   187      
2      187            
3      2689            
4      4901            
5      2521            
6      2433
7                   210      
8      210            
9      934            
10      1333            
11      736            
12                   218               
13      218            
14      2450            
15      653            

the problem is that i have to assign the value for NGROUP (second column) for all the records.

e.g. records from 2 to 6 should receive group 187
      records from 8 to 11 should receive group 210
      records from 13 to 15 should receive group 218

and so on on the whole table...

any clues?

the vba should actually read the NGROUP field of every record and copy it in the following ones until it finds a new value that is not null....

what is the best way to put some order in this table???

thanks in advance!!!


     
0
Comment
Question by:catalini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 9

Expert Comment

by:pradapkumar
ID: 18007120
Hi post some more details about your problem as detailed example.
0
 
LVL 85
ID: 18007173
How do you determine what NGROUP a particular record belongs to? For example, why does record #6 belong to NGROUP 187 and not 210? Without some form of logical grouping, you'll not be able to determine which records belong to what NGROUP.
0
 
LVL 15

Accepted Solution

by:
jmantha709 earned 2000 total points
ID: 18007174
Something like this (Put this sub in a new module, adjust it for your needs, change the table name and try it... Make a backup first) :

Public sub ArrangeTable()

dim rs as dao.recordset
dim strGroup as string

strGroup = ""
set rs = currentdb.openrecordset("YourTableName")

do while not rs.eof
  If rs("NGROUP") <> "" Then
    strGroup = rs("NGROUP")
  Else
    rs.edit
      rs("NGROUP") = strGroup
    rs.Update
  End if
  rs.movenext
loop
rs.close

End Sub
0
 
LVL 15

Expert Comment

by:jmantha709
ID: 18007178
Replace this line :

set rs = currentdb.openrecordset("YourTableName")

With :

set rs = currentdb.openrecordset("SELECT * FROM YourTableName ORDER BY ID")
0
 

Author Comment

by:catalini
ID: 18007370
LSMconsulting... the group goes in ascending order... following the ID structure...

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question