Results 1 to 5 of 5
  1. #1
    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

  2. #2
    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.

  3. #3
    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

  4. #4
    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

  5. #5
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •