473,568 Members | 2,935 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Move a Record Up/Down in a Continuous Form !

Hi !!

In a Continuous Form with say 10 records, I'd like to have 1 button
with an "UP" Arrow & another button with a "DOWN" arrow. By pressing
either the Up or the Down Arrow, I'd like the user to be able to MOVE
the records up or down the order.

Something like in a WinAmp or MusicMatch Playlist.

A little sample code would be much appreciated.

Thanks & Bst Rgds,
Prakash.

Nov 13 '05 #1
6 15777
jv
docmd.GoToRecor d,,acnext
docmd.GoToRecor d,,acprevious

Nov 13 '05 #2
On 29 Jun 2005 06:22:56 -0700, "Prakash" <si****@omantel .net.om>
wrote:
Hi !!

In a Continuous Form with say 10 records, I'd like to have 1 button
with an "UP" Arrow & another button with a "DOWN" arrow. By pressing
either the Up or the Down Arrow, I'd like the user to be able to MOVE
the records up or down the order.
This is not trivial. Your continuous form has a recordsource and that
recordsource is probably ordered based on some Order By clause. There
is no way that Access can, by itself, modify the order of the records
it displays unless the underlying values that are used by the Order By
clause are changed. Hence, in general, it just can't be done.

But let's assume that you have a field in your table/query established
for this ordering. You will need to modify that field so that the
ordering values are changed and then requery the continuous form so
that the records are re-displayed.
Something like in a WinAmp or MusicMatch Playlist.

A little sample code would be much appreciated.


No sample code from me, but an idea or two. Assuming you have your
field available for ordering the display, you will need to establish
rules on how that field is built. One way would be to have it be a
text field with length of x + 1 bytes. Use the leftmost x bytes to
establish your order and leave the rightmost byte set to 5.

When re-establishing this field for a record you wish to move up, you
will replace its value with the value of the record immediately above
and change the rightmost byte to 4. If down, the record immediately
below and 6.

Then re-establish the temporary ordering (using whatever mechanism you
used to establish it in the first case, substituting the ordering
field for the original criteria), requery, and you are done.

Somebody else may come up with a routine that establishes the values
of the ordering field for you.

mike

Nov 13 '05 #3
To stop errors from jumping out at you if you're at the first or last
record, use this:

Up button:
If Me.CurrentRecor d > 1 Then
DoCmd.GoToRecor d , , acPrevious
End If

Down button:
If Me.CurrentRecor d <= Me.RecordsetClo ne.RecordCount Then
DoCmd.GoToRecor d , , acNext
End If

jv wrote:
docmd.GoToRecor d,,acnext
docmd.GoToRecor d,,acprevious


Nov 13 '05 #4
No, that doesn't move records, just the focus or pointer or cursor

jv wrote:
docmd.GoToRecor d,,acnext
docmd.GoToRecor d,,acprevious


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #5
Have a sequence number field with your records. Let's call it seqno.

Have your records sequentially numbered.

Then, for the Down button's Click event: (air code, watch line wrap)

sub btnDown_Click()
dim nHold as long, nMax as long
nhold=me.seqno
nMax=dmax("seqn o","yourTable") +1'we'll park the first entry there
currentdb.execu te "update yourtable set seqno=" & nmax & " where
seqno=" & nhold
currentdb.execu te "update yourtable set seqno=" & nhold & " where
seqno=" & nhold+1
currentdb.execu te "update yourtable set seqno=" & nhold+1 & " where
seqno=" & nmax
end sub

Prakash wrote:
Hi !!

In a Continuous Form with say 10 records, I'd like to have 1 button
with an "UP" Arrow & another button with a "DOWN" arrow. By pressing
either the Up or the Down Arrow, I'd like the user to be able to MOVE
the records up or down the order.

Something like in a WinAmp or MusicMatch Playlist.

A little sample code would be much appreciated.

Thanks & Bst Rgds,
Prakash.


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #6
"Prakash" <si****@omantel .net.om> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Hi !!

In a Continuous Form with say 10 records, I'd like to have 1 button
with an "UP" Arrow & another button with a "DOWN" arrow. By pressing
either the Up or the Down Arrow, I'd like the user to be able to MOVE
the records up or down the order.

Something like in a WinAmp or MusicMatch Playlist.

A little sample code would be much appreciated.

Thanks & Bst Rgds,
Prakash.


First, you'll need to add an integer field to your recordset. I'll call it
[Position]. Then you need to populate that field by cycling thru the
recordset in the initial sort order, setting [Position] sequentially (ie: 1,
2, 3, 4, ...)
Now for the code (caution: aircode)

Assume that you have a button to move the selected record "up" one position:

Private Sub btnUp_Click()
If Me!Position <= 1 Then
MsgBox "This record cannot move up"
Exit Sub
End If
Dim NewPos As Integer
NewPos = Me!Position - 1
Me!Position = NewPos
DoCmd.GoToRecor d , , acPrevious
Me!Position = Me!Position + 1
Me.Requery
Me.Position.Set Focus
DoCmd.FindRecor d NewPos
End Sub

Good Luck,
Fred Zuckerman
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3159
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. Tables: (abbreviated) TblDivision DivisionID
1
2953
by: chfran | last post by:
I have a form (continuous) that show me data from a table (not a query). I can only modify and move between the data of the first record. I cannot move to the 2nd, 3rd, or 85th record, only the first. I don't know if I've turned on something unintentionally or what. Any insights? chfran
1
4855
by: Bill | last post by:
Problem: Combo box data disappears from view when a requery is done See "Background" below for details on tables, forms & controls On a form, I want to use the setting of bound combo box C1 to limit what is displayed in bound combo box C2. When I display Tbl-A records on a continuous form, and navigate away from record 1 to record 2,...
1
5888
by: Catriona | last post by:
I am developing an Access application where users insert bill records for an electricity account by clicking on a new button. The required workflow is 1) New button clicked 2) New record appears with some field populated per defaults for account and some based on previous records - eg dates 3) Save button clicked 4) Record validated and...
1
2954
by: JUM | last post by:
This message is for Stephen Lebans and all users using the clsControlData in ContinuousFormsCurrentRowVer7.mdb. First of all many thanks for writing this code which gives the value of a textbox at the cursor position in a continuous form, even if it is not the current row. It helped me a lot. However two remarks : - The example from...
3
11574
by: eighthman11 | last post by:
Using Access 2000. I have a continuous form which for simplicity sack has two fields Social Security Number and Last Name. In the header of the continuous form I have a textbox where you can type in any part of a social security number and when you do I want it to take the user to the closest match SSN record in the continuous form. ...
9
7116
by: OllyJ | last post by:
Hi guys, I have a continuous form and one field is Day / Night, where a 'D' or 'N' is contained to represent each. Is it possible to write code for the 'on current' of the form to ensure a box contained within the specific record is one colour for those records with 'D' and another for those with 'N'? I used for...each...next statement...
2
3138
by: ChipR | last post by:
I'm suddenly having a major problem trying to switch between rows in a continuous form in Access 2007. The form represents a timesheet and has a row for each activity that an employee may work on. There are 14 columns on the form for the days in the pay period, and each day is a text box, basically simulating a spreadsheet. So a row is a record...
8
2067
by: Dan2kx | last post by:
New question.... I have my continous form constructed of data from a query, i want to select records to edit (See thread) using unbound tickboxes, how can i link these? Thanks (again), Dan
0
7693
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7665
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6277
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5501
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3651
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
933
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.