Results 1 to 5 of 5
  1. #1
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43

    Data not filtered after selecting item in the list box

    Sir,

    I used two forms named frm_edit item and frm_search for search item. The item is edited in the edit form. In order to view the item i used from search. on double click the selected item in the list box it displays the infomation about the item but when it try to open the frm_edit it display the no 1 record not the selected record. Kindly help me in this regards.listofitem.zip
    Last edited by sukhjinder; 08-15-2017 at 02:13 AM. Reason: attachment

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    the list box will have 2 columns, ClientName, ID
    the list box must be bound to the key (bound column= 2)
    the list box number of columns =2
    the user sees the names in col.1, but col.2 is invisible using column widths; 2;0

    then when user dbl-clicks the item in list box, it opens the detail via the key

    Code:
    sub lstBox_dbl_click()
      docmd.open "frm_Edit",,,"[id]=" & me.listBox
    end sub

  3. #3
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43

    Not working the with adjustment

    It is not working with the change in the code with varItemID_PK i am getting the ID of the item from the item selected in the list box. But the same ID is not linking with the frm_item_entry on opening.

    Quote Originally Posted by ranman256 View Post
    the list box will have 2 columns, ClientName, ID
    the list box must be bound to the key (bound column= 2)
    the list box number of columns =2
    the user sees the names in col.1, but col.2 is invisible using column widths; 2;0

    then when user dbl-clicks the item in list box, it opens the detail via the key

    Code:
    sub lstBox_dbl_click()
      docmd.open "frm_Edit",,,"[id]=" & me.listBox
    end sub

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,389
    frm_Item_entry is unbound and has its fields set via a defined recordset (rs). When the form opens, it has to know which record to display, so I used the openargs to pass the value from frm_search to frm_Item_entry so that the rs.findfirst could be used.
    Also I changed the name of listbox from listbox to lstSearch. I think listbox is a reserved word.
    In frm_Search:
    Code:
    Dim Response As Integer
        Response = MsgBox("details" & vbCrLf & _
            "----" & vbCrLf & _
            "ID:- " & varID_PK & vbCrLf & _
            "Item:- " & varItemname & vbCrLf & _
            "Category " & varCategory & vbCrLf & _
            "Type:-" & varType & " " & vbCrLf & vbCrLf & _
            "Belongs To:-" & varBelongsto & " " & vbCrLf & vbCrLf & _
            "For more information,Click OK", vbOKCancel, "Detailed information of item")
            
        If Response = vbOK Then
            Debug.Print lstSearch.Column(0)
            DoCmd.OpenForm "frm_item_entry", , , , , , lstSearch.Column(0)
        Else
    In form frm_Item_entry:
    Code:
    Private Sub Form_Load()
        Set db = CurrentDb
        Set rs = db.OpenRecordset("tbl_item", dbOpenDynaset, dbSeeChanges)
        rs.FindFirst "itemID_PK = " & Me.OpenArgs
        refreshdata
        Me.txtitemid.Visible = True
        Me.lblitemid.Visible = True
    End Sub

  5. #5
    sukhjinder's Avatar
    sukhjinder is offline Beginner
    Windows 10 Access 2016
    Join Date
    May 2016
    Posts
    43
    Thanks a lot dear works like a charm!

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

Similar Threads

  1. Selecting item by category
    By mr steev in forum Access
    Replies: 1
    Last Post: 02-25-2015, 03:29 PM
  2. Replies: 9
    Last Post: 11-24-2014, 02:20 PM
  3. Replies: 14
    Last Post: 05-08-2013, 03:08 PM
  4. Selecting a combobox item with VBA
    By tylerg11 in forum Forms
    Replies: 6
    Last Post: 04-19-2012, 12:30 PM
  5. Replies: 2
    Last Post: 04-05-2012, 08:39 PM

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