mmoore500
asked on
Record Navigation with VB script.
I have an access database that I view through IE. I wanted to add a field that allows the user to navigate to a specific record in the database using the record "ID."
I found this code on the Microsoft website and it works, sort of. When the user enters a number, it navigates to absolute record number (ie. If I enter 10 into the field, the returned page may be the record with the "ID" 17, because some other records in between 1 and 10 have been deleted).
How can I get this script to navigate to the record "ID #" and not its absolute place in the record set?
I found this code on the Microsoft website and it works, sort of. When the user enters a number, it navigates to absolute record number (ie. If I enter 10 into the field, the returned page may be the record with the "ID" 17, because some other records in between 1 and 10 have been deleted).
How can I get this script to navigate to the record "ID #" and not its absolute place in the record set?
'Trap the ENTER key.
If window.event.keyCode = 13 Then
'Make sure the number entered is greater than zero.
If txtNavRecord.value > 0 Then
'Move to the specified record.
MSODSC.DefaultRecordset.AbsolutePosition = txtNavRecord.value
'Clear the text box.
txtNavRecord.value = ""
'Suppress the Enter key to avoid moving
'to a new line in the text box.
window.event.returnValue = False
Else
'Clear the text box and suppress the Enter key.
txtNavRecord.value = ""
window.event.returnValue = False
End If
End If
ASKER
When you say: "MYIDField=" & somevalue
what should I type exactly?
I understand that for "MyIDField" I should replace it with "ID" because that is the column I need to search.
what does "& somevalue" mean?
what should I type exactly?
I understand that for "MyIDField" I should replace it with "ID" because that is the column I need to search.
what does "& somevalue" mean?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could the find command, eg
MSODSC.DefaultRecordset.Fi
the numbers on the end represent the arguments to the find command
Taken from help
Criteria
A String value that contains a statement specifying the column name, comparison operator, and value to use in the search.
SkipRows
Optional. A Long value, whose default value is zero, that specifies the row offset from the current row or Start bookmark to begin the search. By default, the search will start on the current row.
SearchDirection
Optional. A SearchDirectionEnum value that specifies whether the search should begin on the current row or the next available row in the direction of the search. An unsuccessful search stops at the end of the Recordset if the value is adSearchForward. An unsuccessful search stops at the start of the Recordset if the value is adSearchBackward.
Start
Optional. A Variant bookmark that functions as the starting position for the search.