Module: Forms_Jet in Category Microsoft Access : Forms from Total Visual SourceBook

Routines for Microsoft Access forms using Jet (for MDB/ACCDB, not ADP) using VBA.

Procedure Name Type Description
(Declarations) Declarations Declarations and private variables for the modForms_Jet module.
GetFormRecordNumberDAO Procedure Get the current record number of a form in a Jet database. Note that the concept of a record number is not particularly useful (or even desirable) in a relational database like Access. However, when developing your own custom navigation bars in forms, you may want to include the current record number like the standard Access form does. This function uses a DAO property called AbsolutePosition that returns the current record number. This number is not guaranteed to be accurate in multi-user scenarios and should be used for informational/display purposes only. Never rely on a record number for programmatic navigation purposes. The most common way to call this function is from a form's OnCurrent event. This allows you to keep an up-to-date value as the user moves through the form's records.
GetFormsPercentPositionDAO Procedure Get the percent position of a form in a Jet database. Note that this is not available for forms in ADPs, since those recordsets do not support PercentPosition. This is useful if you are creating your own custom navigation buttons on a form and want to display a progress meter with the percentage position. This function uses the form's RecordsetClone method. As such, it requires that the form be bound to a data source.
Note: The number returned is an integer, so the percent position value is approximate. The most common way to call this function is from a form's OnCurrent event. This allows you to keep an up-to-date value as the user moves through the form's records. This number is not guaranteed to be accurate in multi-user scenarios and should be used for informational/display purposes only. Never rely on a record number for programmatic navigation purposes.
IsFormOnFirstRecordDAO Procedure Determine if the current record of a form in a Jet database is on the first record. This can be useful if you have custom navigation buttons for 'move first', 'move next', etc. and you want to disable the 'move first' button when the form is on the first record.
IsFormOnLastRecordDAO Procedure Determine if the current record of a form in a Jet database is on the last record. This can be useful if you have custom navigation buttons for 'move first', 'move next', etc. and you want to disable the 'move last' button when the form is on the last record.
ListFillTables Procedure Provides a list fill function for a list/combo box for a list of tables in a Jet database.
ListFillRelations Procedure Provides a list fill function for a list/combo box for a list of relations in a Jet database.
ObjectNamesToArray Procedure Loads an array with names of all of an object type.
' Example of modForms_Jet
'
' To try this example, do the following:
' 1. Create a new form in your copy of Sample.mdb (in the Total Visual SourceBook sample directory)
' 2. Set the RecordSource property to the 'Categories'
' 3. Add a command button named 'cmdTest'
' 4. Create the following list boxes:
'       'lstTables'
'       'lstRelations'
' 5. Paste this code into the form's module

Private Sub cmdTest_Click()

  ' Example of GetFormRecordNumber
  Debug.Print "Record number: " & GetFormRecordNumberDAO(Me)

  ' Example of GetFormsPercentPosition
  Debug.Print "Percent position: " & GetFormsPercentPositionDAO(Me)

  ' Example of IsFormOnFirstRecord
  If IsFormOnFirstRecordDAO(Me) Then
    Debug.Print "On first record"
  Else
    Debug.Print "Not on first record"
  End If

  ' Example of IsFormOnLastRecord
  If IsFormOnLastRecordDAO(Me) Then
    Debug.Print "On last record"
  Else
    Debug.Print "Not on last record"
  End If

End Sub

Private Sub Form_Open(Cancel As Integer)
  lstTables.RowSourceType = "ListFillTables"
  lstRelations.RowSourceType = "ListFillRelations"
End Sub

Total Visual SourceBook The source code in Total Visual Sourcebook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Total Visual SourceBook is written for the needs of a developer using a source code library covering the many challenges you face. Countless developers over the years have told us they learned some or much of their development skills and tricks from our code. You can too!

Additional Resources

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!


View all FMS products for Microsoft Access All Our Microsoft Access Products

Reviews

Reader Choice Award for MS Access Source Code Library
Reader Choice

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

SourceBook Info

Additional Info

Question

 

 

Free Product Catalog from FMS