Custom Nav buttons

krowe

Registered User.
Local time
Today, 01:52
Joined
Mar 29, 2011
Messages
159
Hi

I'm not liking the built in nav button placement on the screen so want to put my own in.

MS advise how to do it here:
http://support.microsoft.com/kb/104683

Code:
Option Compare Database
'*******************************************
   ' MODULE DECLARATION SECTION
   '*******************************************
   Option Explicit
   Dim RetVal As Variant
   '*******************************************
   ' MODULE FUNCTIONS
   '*******************************************
   Function GotoFirstRecord()
      RetVal = GotoRecord(A_FIRST)
   End Function
   Function GotoLastRecord()
      RetVal = GotoRecord(A_LAST)
   End Function
   Function GotoNextRecord()
      RetVal = GotoRecord(A_NEXT)
   End Function
   Function GotoPrevRecord()
      RetVal = GotoRecord(A_PREVIOUS)
   End Function
   Function GotoFirstSubRecord(SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoFirstRecord()
   End Function
   Function GotoLastSubRecord(SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoLastRecord()
   End Function
   Function GotoNextSubRecord(SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoNextRecord()
   End Function
   Function GotoPrevSubRecord(SubControlName As String)
      DoCmd GoToControl SubControlName
      RetVal = GotoPrevRecord()
   End Function
   Function GotoRecord(Direction)
      On Error Resume Next
      DoCmd GotoRecord, , Direction
   End Function

but it doesn't include an add new button.

what would I add to the code to get this function for forms and subforms.

Thanks

Kev
 
Use the add command button wizard to a form and select new record then use the vba that it generates.
 
Or if you want to use the current scheme add a new function to your module:

Code:
Function GoToNewRecord()
    RetVal = GoToRecord(A_NEWREC)
End Function

JR
 
Wow, that was quick!!!

Ok, so im testing this code and getting problems.

I cant seem to compile it. I get a syntax error on this line:
DoCmd GoToControl SubControlName

what is the correct syntax for this?

Thanks for your help so far
 
Actually, I have now looked at the wizard nav buttons, I didn't know that was so easy!

Thanks again for your help
 
Make sure that all DoCmd has a periode after it.

DoCmd.GotoControl

JR
 

Users who are viewing this thread

Back
Top Bottom