If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > Event For Navigation Buttons

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
Join Date: Dec 2003
Posts: 9
Event For Navigation Buttons

Hi,

I have a from in which i have placed the navigation buttons (default). Is there any event to trap when the user clicks the next record button or previous record button. These buttons are the Access Built ins and not customised. Expecting help...

Lax
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Jun 2004
Location: Florida, US
Posts: 521
you could either provide your own navigation buttons or you can catch movements through records with oncurrent event of the form. though oncurrent won't provide you any specific details about if user moved to next record or previous.
__________________
ghozy.
Reply With Quote
  #3 (permalink)  
Old
Stuck on my opinions...
 
Join Date: Nov 2003
Posts: 1,487
You can indeed use the OnCurrent event of your Form but you will need to place some code (above all other code) into the event. Here is the code:

Of course, you will want to replace the message boxes with whatever code you want.

Code:
	Static RecordNum As Long
	If RecordNum > 0 Then
	  If Me.CurrentRecord > RecordNum Then
		 MsgBox "Next Record Selected!"
	  ElseIf Me.CurrentRecord < RecordNum Then
		 MsgBox "Previous Record Selected!"
	  End If
	End If
	RecordNum = Me.CurrentRecord
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Mar 2004
Location: Berlin, Germany
Posts: 107
hi cyber

i saw you using a static instead of let's say a private. can you tell me the difference between static and general global vars in vba?

a little "extension"
Static RecordNum As Long
if RecordNum > 0 Then
If Me.CurrentRecord > RecordNum Then
if Me.CurrentRecord = Me.Recordset.RecordCount then
MsgBox "Last Record Selected"
else
MsgBox "Next Record Selected!"
endif
ElseIf Me.CurrentRecord < RecordNum Then
if Me.CurrentRecord = 1 then
MsgBox "First Record Selected"
else
MsgBox "Previous Record Selected!"
End If
End If
RecordNum = Me.CurrentRecord
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Jul 2004
Location: Inverurie
Posts: 628
Static Procedures

If a procedure is declared as Static, all the variables declared within the procedure maintain their values between calls to the procedure. This is an alternative to explicitly declaring each variable within the procedure as Static. Here is an example of a Static procedure:

Code:
Static Sub IncrementThem()

   Dim intCounter1 As Integer

   Dim intCounter2 As Integer

   Dim intCounter3 As Integer

   intCounter1 = intCounter1 + 1

   intCounter2 = intCounter2 + 1

   intCounter3 = intCounter3 + 1

   MsgBox intCounter1 & " - " & intCounter2 & " - " & intCounter3

End Sub
Ordinarily, each variable in this procedure is reinitialized each time the procedure is run. This means that all 1s appear in the message box each time the procedure is run. Because the procedure is declared as Static, the variables within it retain their values from call to call. Each time the procedure is run, the values within the message box increase.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On