473,791 Members | 3,251 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Next Record Button. Combo box. Code sub not working

41 New Member
Hi All,

I am now on the next part of my quest.

I have built my Form, which has used subforms to show my records and what I need to complete as the POL authority.

I am now trying to jazz the form up so I thought of adding a next record and previous record button.

I added two combo boxes called Next_Record and Previous_Button .

I selected code builder and added the following scripts.

Private Sub Next_Record_Cli ck()

Me.POL_Ref.SetF ocus

If (Me.POL_Ref.Lis tIndex = Me.POL_Ref.List Count - 1) Then

Else
Me.POL_Ref.List Index = (Me.POL_Ref.Lis tIndex + 1)
End If

End Sub

Private Sub Previous_Button _Click()
Me.POL_Ref.SetF ocus

If (Me.POL_Ref.Lis tIndex = 0) Then

Else
Me.POL_Ref.List Index = (Me.POL_Ref.Lis tIndex - 1)
End If
End Sub

I go onto the my report screen and press the buttons and nothing happens no error or anything.

I have tried to use the unique number in the POL_Ref field of my form?

I can't see the wood for the trees now.
Jan 10 '08 #1
6 4825
missinglinq
3,532 Recognized Expert Specialist
You have, indeed, over complicated things! I think the first thing you need to do is to delete everything you have so far; buttons, comboboxes and code. To do otherwise is only going to confuse things. Place two buttons on your form, naming them Go2Next and Go2Previous. Then place this code behind the appropriate button:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Go2Next_Click()
  2.  On Error GoTo Err_Go2Next_Click
  3.  
  4.     DoCmd.GoToRecord , , acNext
  5.  
  6. Exit_Go2Next_Click:
  7.  
  8.    Exit Sub
  9.  
  10.  Err_Go2Next_Click:
  11.  
  12.  If Err.Number = 2105 Then
  13.    MsgBox "This is the Last Record"
  14.  Else
  15.    MsgBox Err.Description
  16.    Resume Exit_Go2Next_Click
  17.  End If
  18.  
  19. End Sub
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Go2Previous_Click()
  2. On Error GoTo Err_Go2Previous_Click
  3.  
  4. DoCmd.GoToRecord , , acPrevious
  5.  
  6. Exit_Go2Previous_Click:
  7.  
  8.     Exit Sub
  9.  
  10. Err_Go2Previous_Click:
  11.  
  12. If Err.Number = 2105 Then
  13.     MsgBox "This is the First Record"
  14. Else
  15.     MsgBox Err.Description
  16.     Resume Exit_Go2Previous_Click
  17. End If
  18.  
  19. End Sub
If the user is at the first record and tries to go to the previous record, a message box will pop up explaining this. If at the last record and the user tries to go to the next record, this, too, will be explained.

Linq ;0)>
Jan 10 '08 #2
jambonjamasb
41 New Member
LOL thank you so much. I will try this in the morning as I am too tired to see the screen now.
Jan 10 '08 #3
missinglinq
3,532 Recognized Expert Specialist
Good call! After 15 years I can tell you, it's almost always counter- productive to attempt programming when you're tired!

Linq ;0)>
Jan 10 '08 #4
jambonjamasb
41 New Member
Thanks Miss Ingling,

I did the following at it seems to work.

Private Sub Command23_Click ()
On Error GoTo Err_Command23_C lick


DoCmd.GoToRecor d , , acNext

Exit_Command23_ Click:
Exit Sub

Err_Command23_C lick:
MsgBox Err.Description
Resume Exit_Command23_ Click

End Sub
Private Sub Command24_Click ()
On Error GoTo Err_Command24_C lick


DoCmd.GoToRecor d , , acPrevious

Exit_Command24_ Click:
Exit Sub

Err_Command24_C lick:
MsgBox Err.Description
Resume Exit_Command24_ Click

End Sub

LOL Which is basically what you said. Thanks again you are a star.
Jan 10 '08 #5
missinglinq
3,532 Recognized Expert Specialist
Glad you got it figured out! Be aware, though, that if, at the beginning or end of your recordset, the user tries to move again, they will get an error message that says "You can't go to the specified record" without any other explanation! Some users find this confusing!

Linq ;0)>
Jan 10 '08 #6
jambonjamasb
41 New Member
Thank you I will try to change it then.
Jan 10 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
2268
by: Megan | last post by:
Hi everybody- I inherited a database that somehow uses a bound combo box as a record selector. Let me give you some background. The form is based on data from 2 tables. The first table, Person, records info about a person. The second table, Case, records information about a person's case, almost like a human resources database. The primary key of the table, person, is his/ her social security number. The primary key of the other...
6
2747
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are mostly handling let say 5 companies. Every time I have to navigate or choose the find record button to get the right company. I am looking fo a feature to have listed in a combo list the last 5 visited records ("recently visited records").
7
9455
by: gjoneshtfc | last post by:
Hello I want to search my database for a vehicle registration number but before i can search using the Find Record button i created i have to click in the registration field so that it is that one that is being searched. Is there any way to just click the button and by default it searches the registration field? Or... is there a way where I can get the user to type in the registration number in a text field then click a command button...
1
1960
by: foothills bhc | last post by:
I have a problem with verifying content of controls on a form before closing the form or moving to the next form "record" (i.e., when moving to the next row of my form's record source). HERE'S THE LONG EXPLANATION OF THE PROBLEM First, A Description of the Form: I have developed a form for entering survey questionnaire data. The data to be entred on the form could be considered as two kinds of information. One kind could be called...
3
2477
by: mf193 | last post by:
Hi, I have a table of around 1000 rows; patient records. Each row is individually defined by a Patient ID number which is my primary key. I have made a simple form to display patient information for the secretaries working in the office. I would like them to be able to easily search through all the records using a combo box, that they can just type in the person's name. I have managed to make it work so far as when the last name is...
6
5343
by: AppDev63 | last post by:
I've been struggling with a form. On the left side of the form I've got data from a table of invoices, and on the right side I've got a combo box with data from a table of payments. The user scrolls through the invoices on the left and matches each one up with a payment from the combo box on the right. The common field is an order number, but the relationship between invoices and payments must be created manually by the user matching up the...
6
5034
by: banderson | last post by:
Hello, I have a form and a combo box that I use to filter the form to particular records. I also have an "add new" button that, when clicked, adds a new record. My problem is that the filter combo box stays on the old selection when the new record pops up. I would like to have the combo box clear or set to a default value of "New" when the Add New button is clicked or when the user clicks on the * (new record) button in the navigation bar. ...
1
1730
by: Coll | last post by:
I'm working on a database that someone else created. I have a form - frm_main that is based on a query that is based on two tables. The join is such that the first table tbl_JCN has all records included in the query, but the second table tbl_SOC only has matching records displayed. On the form (frm_main), there is a combo box - you can make a selection and the form filters to display that record. There is also a delete record button. When...
0
2708
by: solargovind | last post by:
Hello, I have few problem with Dlookup condition. I need to retrieve next record or previous record based on certain condition. The conditions are set in in the combo box. Here, I am trying to display the records in the text box based on my selection. I have given my selection in the combo box. For example from the student table, I am trying to display as below... a). Who are all coming from "Newyork" city in the 7th standard class. ...
0
9669
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10428
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10156
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9997
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9030
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5435
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2916
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.