Results 1 to 2 of 2
  1. #1
    leonardbd is offline Novice
    Windows 7 32bit Access 2013
    Join Date
    Mar 2015
    Posts
    3

    Insert Value from subForm data and apply filter in the Mainform data fields

    Hi,
    I have a Form with a Table/Query record source. And have 5 data fields (AssetID, Category, Model, Brand, Status) to that form bound with it's record source table/query. I have another Unbound text box "txtAssetID" where wnat to insert a value from another subform data by a Insert button (VB code) in that SubForm. The Unbound txt box "txtAssetID" will populate with inserted value and apply a filter and show the related data in 5 bounded filed from the Table/Query.
    My Subform can insert the Subform's selected data with a Insert button with the button click event code:

    Private Sub btnInsert_Click()
    Me.Refresh
    If Not IsNull(txtAssetID) Then
    Forms![Asset-Form].Form.txtAssetID= Me.AssetID
    End If
    DoCmd.Close


    End Sub

    This code insert the value to the Main form [Asset-Form] from the AssetID field of the Subform and . And for filter data, the "txtAssetID" unbound text box has after update event code:

    Private Sub txtAssetID_AfterUpdate()
    Me.Filter = "AssetID=" & Me.txtAssetID
    Me.FilterOn = True

    End Sub


    My problem is , if I type the AssetID in to unbound txt box "txtAssetID" and press Enter, it filters the record and show the data in all five fields. But If I insert the data in to the "txtAssetID" from the subform, nothing happens. It didn't filter anything.

    Appreciate your expert solution to work it out.
    Thanks
    Regards
    Leo

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Can you post a jpg of your tables and relationships?( A screen capture of your relationships window.)
    Extend tables so that all fields are visible.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Apply second filter to filtered data
    By gemadan96 in forum Forms
    Replies: 2
    Last Post: 12-30-2013, 12:46 PM
  2. Replies: 2
    Last Post: 02-25-2013, 10:47 AM
  3. Filter a subform based on mainform
    By Cheshire101 in forum Queries
    Replies: 3
    Last Post: 01-06-2011, 12:56 PM
  4. Replies: 5
    Last Post: 10-06-2010, 07:28 PM
  5. copying data from subform to mainform
    By wasim_sono in forum Forms
    Replies: 0
    Last Post: 03-10-2006, 04:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums