Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2011
    Posts
    20

    Post How to Restrict the Listbox on double click

    Hi All



    Im using list box with multiple fields in my access project and i have written code in listbox's double click event.

    I have included column headers in the list box.

    What im doing is im getting a list box field value when double clicking it and retreving datas from the table and filling in text boxes with that value.

    For that " I should restrict such that i should not suppose to get the value if i double click on column header or Empty Rows in the List Box"

    Plz tell the code to accomplish this.

  2. #2
    apr pillai's Avatar
    apr pillai is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    May 2010
    Location
    Alappuzha, India
    Posts
    209
    When you Double-Click on the Header or Empty area of a listbox it returns Null Value. Check the returned value, if Null then Exit the Sub-Routine without taking any action.

    Code:
    Private Sub lstDat1_DblClick(Cancel As Integer)
       If IsNull([lstDat1]) Then
             Exit Sub
       End If
       DoCmd.OpenForm "MyForm", acNormal
    End Sub

  3. #3
    Join Date
    Jun 2011
    Posts
    20

    Post Re:How to Restrict the Listbox on double click

    Quote Originally Posted by apr pillai View Post
    When you Double-Click on the Header or Empty area of a listbox it returns Null Value. Check the returned value, if Null then Exit the Sub-Routine without taking any action.

    Code:
    Private Sub lstDat1_DblClick(Cancel As Integer)
       If IsNull([lstDat1]) Then
             Exit Sub
       End If
       DoCmd.OpenForm "MyForm", acNormal
    End Sub
    Hi

    Thanks for your reply.

    Actually after clicking a record in list box, the selection focus goes to that record. Then after clicking the header row or empty row, the selection remains the prior selected record and that value alone is retrieving . Thats where im facing the problem.

    Please Suggest.

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

Similar Threads

  1. Replies: 8
    Last Post: 05-26-2011, 09:23 AM
  2. On Double Click go to Subform
    By Theremin_Ohio in forum Access
    Replies: 2
    Last Post: 03-30-2011, 08:03 AM
  3. Double click combo box to add data
    By sam49 in forum Database Design
    Replies: 29
    Last Post: 03-28-2011, 08:58 AM
  4. Opening another form by double click
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 10-13-2010, 02:19 PM
  5. Rescrolling in ListBox on Double Click
    By jackkent in forum Access
    Replies: 6
    Last Post: 09-28-2010, 11:56 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