Solved

edit a field using VBA...

Posted on 2006-11-24
5
868 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 500 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

707 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