Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter Form Open New Form and Pass Args to Subform

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I have a dialog, where a user can type in any part of a key, to look up possible projects. The results show up in a list box. Double-click the item in the list box, and a new form opens. This new form is unbound, and is set as a normal form. The reason I set it up like this is that the results I want to show for the user, I want to show in datasheet. I can't have the main form be a datasheet, because then I can't have buttons and other controls on the form. For this reason, I set up the "results" form to be unbound with a subform set to datasheet and the results to appear in there.

Now I am trying to figure out how to get the chosen item in the list box (column(1) passed as a filter to the left(field,6) of a subform field on the form that is being opened.

this is the code I have for the filter dialog:

Code:
Private Sub lstBillingKeyResults_DblClick(Cancel As Integer)
On Error GoTo Err_lstBillingKeyResults_DblClick

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmAssetResults"

'stLinkCriteria = "left(Forms!frmAssetResults!frmAssetTrackingSub.Form!AssetTag,6)=" & "'" & [Forms]![frmAssetMain]![lstBillingKeyResults].Column(1) & "'"
DoCmd.OpenForm stDocName
', , , stLinkCriteria
Forms!frmAssetResults.txtAssetArgs = Me.lstBillingKeyResults.Column(1)
DoCmd.Close acForm, "frmAssetMain", acSaveNo

'Forms!Mainform!Subform1.Form.RecordSource

Exit_lstBillingKeyResults_DblClick:
Exit Sub

Err_lstBillingKeyResults_DblClick:
MsgBox Err.Description
Resume Exit_lstBillingKeyResults_DblClick

End Sub

This is what I have in the form frmMain, which is opened:

Code:
Me.txtAssetArgs = [Forms]![frmAssetMain]![lstBillingKeyResults].Column(1)

If Len(Me.txtAssetArgs.Value & vbNullString) = 0 Then
    MsgBox "Must have an asset filter to open asset tracking", vbOKOnly, "Must Choose a Matter Filter"
    DoCmd.OpenForm "frmAssetMain"
    DoCmd.Close acForm, "frmAssetResults"
Else
    Me.frmAssetTrackingSub.Form.Filter = "left(Forms!frmAssetResults!frmAssetTrackingSub.Form!AssetTag,6)=" & "'" & Me.txtAssetArgs & "'"
    Me.frmAssetTrackingSub.Form.FilterOn = True
End If

End Sub

The frmAssetMain is opening, but no filter is being applied. Can someone please help?

thanks :)

misscrf

It is never too late to become what you could have been ~ George Eliot
 
How are ya misscrf . . .

A form in datasheet view is a bound view of a table. A bound continuous form can show the same data, as well as be made to look like a datasheet! ... You keep the full powers of the form.

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top