L
Larry R Harrison Jr
I have Access 2000. I want code in a function--which is
called up from a custom pull-down menu--to go to a
specified record. The idea is if this form ( which is a
continuous form) is showing search results and the user
selects "View...All" it should show all records and THEN
go to the record they had their cursor on prior to
saying "View All" (so they don't lose place with the found
record in the scheme of where it lands amongst them all).
The code looks like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function show_all()
Dim sSQL As String, stX As Integer
stX = Screen.ActiveForm.autoid
MsgBox "stX = " & stX
sSQL = "SELECT tblMain.* FROM tblMain;"
If Not IsLoaded("frmBrowseMain") Then
Call closeallfrms
DoCmd.OpenForm "frmBrowseMain"
End If
Screen.ActiveForm.RecordSource = sSQL
Screen.ActiveForm.Caption = "Showing All Records. Double-
click your selection to open it (or use the OPEN menu)."
DoCmd.FindRecord "[autoid] = " & stX
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It works fine excepts for the DoCmd.FindRecord portion.
It's supposed to match up the record with the proper
autoid. Notice: stX DOES have the proper value (the MsgBox
code helped me confirm this) but it continues to remain at
the 1st record rather than jumping to the one I want.
Tips?
LRH
called up from a custom pull-down menu--to go to a
specified record. The idea is if this form ( which is a
continuous form) is showing search results and the user
selects "View...All" it should show all records and THEN
go to the record they had their cursor on prior to
saying "View All" (so they don't lose place with the found
record in the scheme of where it lands amongst them all).
The code looks like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function show_all()
Dim sSQL As String, stX As Integer
stX = Screen.ActiveForm.autoid
MsgBox "stX = " & stX
sSQL = "SELECT tblMain.* FROM tblMain;"
If Not IsLoaded("frmBrowseMain") Then
Call closeallfrms
DoCmd.OpenForm "frmBrowseMain"
End If
Screen.ActiveForm.RecordSource = sSQL
Screen.ActiveForm.Caption = "Showing All Records. Double-
click your selection to open it (or use the OPEN menu)."
DoCmd.FindRecord "[autoid] = " & stX
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It works fine excepts for the DoCmd.FindRecord portion.
It's supposed to match up the record with the proper
autoid. Notice: stX DOES have the proper value (the MsgBox
code helped me confirm this) but it continues to remain at
the 1st record rather than jumping to the one I want.
Tips?
LRH