Code.GeekInterview.com
  I am new, Sign me up!
 
Code Samples MS Access
 

Navigation made easy


Code ResourceAuthor: Shivanna  

Difficulty Level:

Published: 25th May 2007   Read: 888 times  

Filed in: MS Access
Add Comment


 


Whenever we create forms for data tables it becomes necessary to provide navigation buttons.  Though MS-Access provides built-in navigation buttons, Developers would like to provide standardised, user-friendly button type navigation features in their forms.  The Function FrmNavigate aims to standardise such a feature and thus makes it easier to reuse the code whereever record navigation is required.

Create 4 Buttons - First, Previous, Next and Last For each onclick property in Properties window call the function as shown below

Button        Property            Value
---------------------------------------------------
First              OnClick       =FrmNavigate("First")
Previous      OnClick       =FrmNavigate("Prev")
Next              OnClick       =FrmNavigate("Next")
Last              OnClick       =FrmNavigate("Last")

 

 


Sample Code
  1.  
  2. Public Function FrmNavigate(NavigateTo As String)
  3. On Error Resume Next
  4.     Select Case NavigateTo
  5.         Case "First"
  6.             If ActiveForm.CurrentRecord = 1 Then
  7.                 MsgBox "First Record.", vbExclamation, "User Alert"
  8.             Else
  9.                 DoCmd.RunCommand acCmdRecordsGoToFirst
  10.             End If
  11.         Case "Prev"
  12.             If ActiveForm.CurrentRecord = 1 Then
  13.                 MsgBox "First Record.", vbExclamation, "User Alert"
  14.             Else
  15.                 DoCmd.RunCommand acCmdRecordsGoToPrevious
  16.             End If
  17.         Case "Next"
  18.             If ActiveForm.CurrentRecord = ActiveForm.RecordsetClone.RecordCount Then
  19.                 MsgBox "Last Record.", vbExclamation, "User Alert"
  20.             Else
  21.                 DoCmd.RunCommand acCmdRecordsGoToNext
  22.             End If
  23.         Case "Last"
  24.             If ActiveForm.CurrentRecord = ActiveForm.RecordsetClone.RecordCount Then
  25.                 MsgBox "Last Record.", vbExclamation, "User Alert"
  26.             Else
  27.                 DoCmd.RunCommand acCmdRecordsGoToLast
  28.             End If
  29.     End Select
  30.     ActiveForm.AllowEdits = False
  31. End Function
  32.  
Copyright GeekInterview.com




Next Article: Increment and Decrement Date Value using hot Keys + / -


 

Latest Code Samples

 

Popular Code Samples

 

Related Code Samples

 

Post Comment


Members Please Login

Name:  Email: (Optional. Used for Notification)

Title:
 
Comment:
Validation Code: <=>  (Enter this code in text box)





Popular Coders

# Coder NameHits
1. Lokesh M4414
2. Shivanna2235
3. Rajani1515

Active Coders

# Coder NameCodes
1. Shivanna2
2. Lokesh M2
3. Rajani1

Refined Tags

 

Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact  

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape