Percent Position - Access 2k

L

Leonard Priestley

Could anyone suggest a website that has one or two examples of how to use
the percent position property? It looks as it if ought to be simmple, but
I'm not getting it right.
Thanks
Leonard Priestley
 
W

Wayne Morgan

There is an example in the Help file as listed below:

-----------------------------------------
This example uses the PercentPosition property to show the position of the
current record pointer relative to the beginning of the Recordset.
Sub PercentPositionX()

Dim dbsNorthwind As Database
Dim rstProducts As Recordset
Dim strFind As String
Dim strMessage As String

Set dbsNorthwind = OpenDatabase("Northwind.mdb")
' PercentPosition only works with dynasets or snapshots.
Set rstProducts = dbsNorthwind.OpenRecordset( _
"SELECT ProductName FROM Products " & _
"ORDER BY ProductName", dbOpenSnapshot)

With rstProducts
' Populate the Recordset.
.MoveLast
.MoveFirst

Do While True
' Show current record information and ask user
' for input.
strMessage = "Product: " & !ProductName & vbCr & _
"The record pointer is " & _
Format(.PercentPosition, "##0.0") & _
"% from the " & vbCr & _
"beginning of the Recordset." & vbCr & _
"Please enter a character search string " & _
"for a product name."
strFind = Trim(InputBox(strMessage))
If strFind = "" Then Exit Do

' Try to find a record matching the search string.
.FindFirst "ProductName >= '" & strFind & "'"
If .NoMatch Then .MoveLast
Loop

.Close
End With

dbsNorthwind.Close

End Sub
-----------------------------------------

You can also use this on a form's recordset.

Example:
Forms!Form1.Recordset.PercentPostition

Just remember, this is an approximate position.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top