Next and Previous scroll buttons for like records

spectraflame

Well-known Member
Joined
Dec 18, 2002
Messages
830
Office Version
  1. 365
Platform
  1. Windows
I have a table (tblWorkOrders) that contains records with a WOType like the following:

L04 - 00001
M04 - 00001
L04 - 00002
M04 - 00002
E04 - 00001
E04 - 00002
E04 - 00003
W04 - 00001

I would like to be able to create buttons that when clicked would take me to the next or previous record based on the beginning letter of the WOType field.

Based on the data above, If I had the L04 - 00002 record open and I clicked the next button, a message would pop up saying something like "There are no more additional records" but if I clicked the previous button once, I would then see the L04 - 00001 record. Then if I clicked the previous button again, a message would pop up saying something like "This is the first record for this department".

Matthew
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I've never really considered doing it quite like you request.
Typically, the technique I'd use is to filter the recordset as it is being displayed in the grid, (filter by that character) thus allowing the default methods to work moving forward/backwards.

I'm not sure if there's an easier way off hand, but my first guess is you'd have to write code that searches forward/backwards in the recordset for matches and then to refresh/requery to display that specific data.

Feels cumbersome to me so there's probably an easier way -- perhaps one of the other helpful souls here will speak up and comment.

Mike
 
Upvote 0
When you say default methods, do you mean using the record selectors toolbar? If so, I guess that would work. The users just requested buttons to click, but they really did not say if they had to be on the form or just at the button of the window which is where the selector appears. That may work.

Currently I have an edit screen that allows the user to select the desired department (Electric, Water, Sewer, Maintenance, or Locate) and the status of the Order (Open, Closed, or All). Based on the users selections, I have a combo box that displays the records that meet the criteria. The user then selects the desired record and clicks OK. The record is then opened in a form that allows the user to make certain edits.

The users were looking for a way, that once editing a record for the Electiric department with a status of Open, they could click on the next or previous record button which would take them to the next or previous Electric order that is open for editing.

With your filter suggestion and based on my users selections, would I just set up my form to only display the records that the initial query returned?

Matthew
 
Upvote 0
My mistake - I meant the 'default code that Access generates when you use the wizard to create buttons to move thru records' aka

Code:
DoCmd.GoToRecord , , acPrevious

I like your method, btw.

What if you included code (Next/Previous) on your edit form that:

1) Goes to the form above, and edits the selected value in the combo-box
2) Changes the recordsource in your open edit form
3) Requery/Refreshes to show the information

Mike
 
Upvote 0

Forum statistics

Threads
1,221,825
Messages
6,162,165
Members
451,750
Latest member
dofrancis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top