Search unbound subform records (1 Viewer)

fibayne

Registered User.
Local time
Today, 10:50
Joined
Feb 6, 2005
Messages
236
Hi...I have set up a navigation form which contains 5 unbound subforms that are made visible or not visible thru the on click event of command buttons on the main form, the subforms have a command button with an embedded macro that searches for a record based on what has been keyed to an unbound text box on the subform, this works fine when the sub forms are opened independently of the navigation form but when the search is done from within the main form, the error message is, "....cannot find the referenced from frmAQIFAList" subform, I tried referencing the main form name infront of the subform name but this also doesn't work, perhaps this would be better with code ? or is it because the subforms are unbound ? any help much appreciated Fi
 

burrina

Registered User.
Local time
Today, 03:50
Joined
May 10, 2014
Messages
972
I don't understand your Schema. You say 5 unbound subforms? Are you searching the subforms from the main form or from the subform? Generally this is done via ComboBox.
I don't use macros, so no help there. Please explain more.
 

fibayne

Registered User.
Local time
Today, 10:50
Joined
Feb 6, 2005
Messages
236
Hi..I tried to use the Navigation Form that comes with Access 2010 but found it problematic so have tried to make something similar by placing the 5 subforms, these contain lists of records eg clients, entities, products on the main form, the visible property of them is set to No as are command buttons on the main form used to navigate to reports and other forms based on each of the subforms, the OnClick event of the command buttons on the main form are set to make the relevant subforms and related command buttons on the main form visible, these command buttons work fine, it is the command buttons with the embedded macro on the subforms that aren't working when opened thru the Main Form, which are used to search for a record on the subform, attached is a screen print of the Main Form if this helps and part of the code on the main form which makes the relevant subform and its command buttons visible and the code behind these buttons to open further reports and forms

Private Sub cmdActiveQROPS_Click()
'Hide all but Application List
Me.ApolloQROPS.Visible = False 'MainForm
Me.frmAQApplicationList.Visible = True 'Application List
Me.cmdEntityCards.Visible = True 'Application List
Me.cmdActivity.Visible = True 'Application List
Me.cmdStatement.Visible = True 'Application List
Me.cmdAssetMgmt.Visible = True 'Application List
Me.frmAQIFAList.Visible = False 'IFA List
Me.cmdNewIFA.Visible = False 'IFA List
Me.cmdIFAReports.Visible = False 'IFA List
Me.frmAQINTList.Visible = False 'INT List
Me.cmdNewINT.Visible = False 'INT List
Me.cmdINTReports.Visible = False 'INT List
Me.frmAQContactsList.Visible = False 'Client List
Me.cmdNewClient.Visible = False 'Client List
Me.frmAQTransferSchemeList.Visible = False 'TransferScheme List
Me.cmdNewScheme.Visible = False 'TransferScheme List
Me.frmAQAssetList.Visible = False 'Investment List
Me.cmdNewAsset.Visible = False 'Investment List
Me.frmAQAccountsModule.Visible = False 'Accounts Module
Me.frmAQTrackingOptions.Visible = False 'Tracking Options
End Sub

Private Sub cmdActivity_Click()
DoCmd.OpenForm "frmAQTransactionList", acNormal, "", "[ClientIDFK]=[Forms]![AQNavigationForm]![frmAQApplicationList]![ClientIDFK]"
End Sub

Private Sub cmdStatement_Click()
DoCmd.OpenForm "frmAQClientStatementReports", acNormal
End Sub

Private Sub cmdAssetMgmt_Click()
DoCmd.OpenForm "frmAQAssetMgmtList", acNormal, "", "[ClientID]=[Forms]![AQNavigationForm]![frmAQApplicationList]![ClientIDFK]"
End Sub

Any help or advice appreciated, code rather than the embedded macro would probably be better, if anyone could help with that?
thanks Fi
 

Attachments

  • Main Form.zip
    108.8 KB · Views: 95

JHB

Have been here a while
Local time
Today, 10:50
Joined
Jun 17, 2012
Messages
7,732
Maybe you could post your database with some sample data.
 

fibayne

Registered User.
Local time
Today, 10:50
Joined
Feb 6, 2005
Messages
236
hi ..thanks for your reply JHB I have found some code that does the searches I need rather than using the embedded Macro and also there are no problems with the search being carried out on a subform..

Private Sub txtSearchAssetName_AfterUpdate()
UpdateFilter
End Sub

Private Sub txtSearchAssetType_AfterUpdate()
UpdateFilter
End Sub

Private Sub cboSearchAssetManager_AfterUpdate()
UpdateFilter
End Sub


Private Sub cmdClearFilter_Click()

' Clear the filter boxes and update

Me.txtSearchAssetName = Null
Me.txtSearchAssetType = Null
Me.cboSearchAssetManager = Null

UpdateFilter

End Sub

Private Function UpdateFilter()

Dim a As String

' Build a filter string based on user input


If Not IsNull(Me.txtSearchAssetName) Then
a = a & " AND AssetName LIKE '*" & Me.txtSearchAssetName & "*'"
End If

If Not IsNull(Me.txtSearchAssetType) Then
a = a & " AND AssetTypeLU LIKE '*" & Me.txtSearchAssetType & "*'"
End If
If Not IsNull(Me.cboSearchAssetManager) Then
a = a & " AND AssMgrIDFK = " & Me.cboSearchAssetManager
End If



If a = "" Then
' No filter required
Me.Filter = ""
Me.FilterOn = False
Else
' Add filter to form
Me.Filter = Right(a, Len(a) - 4)
Me.FilterOn = True
End If
 

Users who are viewing this thread

Top Bottom