Opening related form *not* filtered but still at same record

  • Thread starter Thread starter Fred Boer
  • Start date Start date
F

Fred Boer

Hello!

I have a form which shows library patron information, including a continuous
subform which displays the patron's borrowing history. A "Details" button on
the continuous subform opens a related form to display information about the
current book.

As it is, the "related" form's recordsource is filtered to display
information about the current title only. (Code below.). I would like to
experiment with opening the related form *without* the form's recordsource
being filtered, but *with* the form displaying the appropriate book
information. Any suggestions of the best way to go about this?

Thanks!
Fred Boer


Private Sub cmdOpenTitleInformationForm_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm_BookCirculationInformation"

stLinkCriteria = "[Book_ID]=" & Me![txtBookID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
Hi Fred

How about passing the filter string via OpenArgs, and finding the required
record in the Form_Load event procedure:
Private Sub cmdOpenTitleInformationForm_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm_BookCirculationInformation"

stLinkCriteria = "[Book_ID]=" & Me![txtBookID]
DoCmd.OpenForm stDocName, OpenArgs:=stLinkCriteria

End Sub

Then:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) then
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If not .NoMatch then
Me.Bookmark = .Bookmark
End If
End With
End If
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Fred Boer said:
Hello!

I have a form which shows library patron information, including a continuous
subform which displays the patron's borrowing history. A "Details" button on
the continuous subform opens a related form to display information about the
current book.

As it is, the "related" form's recordsource is filtered to display
information about the current title only. (Code below.). I would like to
experiment with opening the related form *without* the form's recordsource
being filtered, but *with* the form displaying the appropriate book
information. Any suggestions of the best way to go about this?

Thanks!
Fred Boer


Private Sub cmdOpenTitleInformationForm_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm_BookCirculationInformation"

stLinkCriteria = "[Book_ID]=" & Me![txtBookID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
Say a form is based on a table that has XXX as the primary key field.

This code would position the form to the record with value 999 of that
field:

(untested)

with me.recordsetclone
.findfirst "[XYZ]=999"
if .nomatch then
msgbox "no such record"
else
me.bookmark = .bookmark
endif
end with

You could pass the relevant PK value to the related form through OpenArgs.
That form could use the above-mentioned code in its Form_Load event to
position to the specified record.

HTH,
TC
 
Thanks to both of you! It seems to work perfectly... Now I need to decide if
I like it or not! <g>

Fred

Graham Mandeno said:
Hi Fred

How about passing the filter string via OpenArgs, and finding the required
record in the Form_Load event procedure:
Private Sub cmdOpenTitleInformationForm_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm_BookCirculationInformation"

stLinkCriteria = "[Book_ID]=" & Me![txtBookID]
DoCmd.OpenForm stDocName, OpenArgs:=stLinkCriteria

End Sub

Then:

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) then
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If not .NoMatch then
Me.Bookmark = .Bookmark
End If
End With
End If
End Sub
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Fred Boer said:
Hello!

I have a form which shows library patron information, including a continuous
subform which displays the patron's borrowing history. A "Details"
button
on
the continuous subform opens a related form to display information about the
current book.

As it is, the "related" form's recordsource is filtered to display
information about the current title only. (Code below.). I would like to
experiment with opening the related form *without* the form's recordsource
being filtered, but *with* the form displaying the appropriate book
information. Any suggestions of the best way to go about this?

Thanks!
Fred Boer


Private Sub cmdOpenTitleInformationForm_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Frm_BookCirculationInformation"

stLinkCriteria = "[Book_ID]=" & Me![txtBookID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
Back
Top