Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2008

Tip: Looking for answers? Try searching our database.

Updating and resequencing display of records based on user input

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TESA0_4 - 28 Mar 2008 10:15 GMT
Hi. I'm a little bit past newbie status, but only just!
I'm developing a Risk Assessment database. The user has to break 'processes'
into a series of discrete 'tasks'. Each 'task' has to be Risk Assessed. I
have a table that records header information about the 'process' and another
table to record information about the 'tasks'. This information is presented
in a form with subform. Each 'task' record is autonumbered.
In addition the user gives each 'task' a task number eg task 1, task 2, task
3 etc that represents the sequence of each 'task' in the 'process'. However,
as the user develops the task list they might decide a new task needs to be
inserted between tasks 2 and 3 or that the task sequencing needs to be
changed from what they have entered.
What I have thought to do is prompt users to enter 'task' numbers in steps
of 10 ie 10, 20, 30 etc so that they can add an extra task with an in-between
number and resort the display of the records.
When the user is happy, I'd like to provide a Command Button that will
automatically run through the 'task' records according to the user defined
sequence giving the 'tasks' sequential numbers 1, 2, 3... etc.
Advice on the coding for the Command Button would be appreciated.
John Spencer - 28 Mar 2008 12:45 GMT
First I would use a number type Double is good that allows decimal
fractions.  That would make it easier to insert steps

Then entry could proceed something like the following.
1.
2
3
oops forgot two steps between 1 and 2
1.3
1.4
Darn forgot a step between those 2
1.35

I would use a query to update the numbering when needed to whole numbers.
That might look something like the following
Assumptions: You have a process identifier - ProcessID- that is a number
field.  If text the DCount statement would need modification

Your button code might look something like the following

Dim strSQL as String
StrSQL = "UPDATE YourTaskTable" & _
" SET TaskOrderNumber = " &  _
"DCount(""*"",""YourTaskTable"","ProcessID="" & ProcessID & "" AND
TaskOrderNumber<="" & TaskOrderNumber)" & _
"WHERE ProcessID =" & Me.ControlWithProcessIDentifier
If Me.Dirty = True then Me.Dirty = False

Currentdb().execute strSQL, DbFailOnError

Me.Requery

Signature

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

> Hi. I'm a little bit past newbie status, but only just!
> I'm developing a Risk Assessment database. The user has to break
[quoted text clipped - 21 lines]
> sequence giving the 'tasks' sequential numbers 1, 2, 3... etc.
> Advice on the coding for the Command Button would be appreciated.
TESA0_4 - 28 Mar 2008 13:17 GMT
Hi. Thanks John. My crude understanding of code enables me to understanding
your suggested solution. Your post appearing a few minutes after my second
post on this thread! I'll have play with your code and decide which solution
to run with.
Your assistance is much appreciated.
Terry
(Sydney Australia)

> First I would use a number type Double is good that allows decimal
> fractions.  That would make it easier to insert steps
[quoted text clipped - 53 lines]
> > sequence giving the 'tasks' sequential numbers 1, 2, 3... etc.
> > Advice on the coding for the Command Button would be appreciated.
TESA0_4 - 28 Mar 2008 12:52 GMT
After a bit more work reading threads and copying code suggestions I have
achieved the result I wanted. Goodness knows if the code is sound, but it
seems to be working!

Public Function Renumber() As Integer
   Dim MyDb As DAO.Database, MyRec As DAO.Recordset
   Dim I As Double
   I = 0
   Set MyDb = CurrentDb
   'Open the table
   Set MyRec = MyDb.OpenRecordset("select [TaskNo] from qryTaskList")
   While Not MyRec.EOF
       MyRec.Edit
           I = I + 1
           'Add a number
           MyRec!TaskNo = I
       MyRec.Update
       MyRec.MoveNext
   Wend
End Function

The Sub that calls the function includes:
   Me.Refresh
   Renumber
   Me.Requery

> Hi. I'm a little bit past newbie status, but only just!
> I'm developing a Risk Assessment database. The user has to break 'processes'
[quoted text clipped - 14 lines]
> sequence giving the 'tasks' sequential numbers 1, 2, 3... etc.
> Advice on the coding for the Command Button would be appreciated.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.