Originally Posted by
jmk909er
This is a little hard to explain but here goes:
I have frmInrto that displays a list of projects by project number, the text box is refered to as "Reference Number". When you click on the project number it opens a full record with details in frmProjects using this code and linking the "Reference Number":
'Enables link in frmIntro to link to frmProjects and filters by Reference Number
Private Sub Reference_Number_Click()
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmProjects"
stLinkCriteria = "[Reference Number]=" & "'" & Me![Reference Number] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub
When the frmProject form opens I want to be able to use the record selector at the bottom to also go into next and previous records. The problem is that with it being filtered by reference number it just shows 1 record in the selector. If I put code in "Me.Filter = no" after it loads it just goes to the first record and then shows all the records.
Is there any way to have it load with the Reference Number selected and still be able to use the record selector to go to other records??
Thanks, Joe
Joe,
to clear the filter use:
It is possible to open the form and then do a "find" then record and make it the current record.
I prefer to use a combo box so that you can search by [Reference Number] but return the Primary key filed that is normally a number value (autonumber data type)
I use the function placed in a code module:
Code:
Public Function bimOpenFormFindRec(pFormName As String, pControlToSearch As String, pFindThis As String, pIsNumeric As Boolean, Optional pOpenArgs As String) As Byte
If pOpenArgs > "" Then
DoCmd.OpenForm pFormName, , , , , , pOpenArgs
Else
DoCmd.OpenForm pFormName
End If
DoCmd.SelectObject A_FORM, pFormName
DoCmd.GoToControl pControlToSearch
If pIsNumeric Then
DoCmd.FindRecord Val(pFindThis), A_ENTIRE, False, acSearchAll, False, A_CURRENT
Else
DoCmd.FindRecord pFindThis, A_ENTIRE, False, acSearchAll, False, A_CURRENT
End If
DoCmd.SelectObject A_FORM, pFormName
DoCmd.GoToControl pControlToSearch
End Function