Results 1 to 5 of 5
  1. #1
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156

    Opening records via Double-Click event on a search form.

    Currently, I have two search forms in my database, and will be making more in the future. While I have the actual search function down, I'm struggling in two places, at the moment:



    1) Can I make it so that users can click anywhere in a row, have that entire row gain focus, and enable them to open the corresponding form by double-clicking anywhere in the row with the record they want to view?

    2) Syntax for a DoCmd.OpenForm where I have two parameters for the "Where". The form I'm working on at the moment is for searching insurance policies. Each policy may have multiple accounts attached to it, and those accounts have to be visible in the search, so multiple entries for each policy are going to appear in the search form (but that's fine). I'm wanting to make it so that a user can click the policy row that also has the account they want to view it with, and have the policy profile form come up with that policy and account. The hard part is that on the policy profile, in order to accomodate for multiple accounts, the account data is shown in a subform (where a combo box on the main form lets users pick which of the associated accounts they want to see in the subform). So I'm thinking the way to do it is to have the account number from the search form move to the combo box on the policy profile form, and that should populate the subform appropriately, but I'm still having a hard time with telling the DoCmd to open the form with the right Policy Number AND Account Number. All the examples I've looked up for syntax help have been for just one.

  2. #2
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156
    Just had a thought! It might help if I provide a visual to show what I mean by selecting an entire row. I'm using "Continuous Forms".
    Click image for larger version. 

Name:	Visual1.jpg 
Views:	9 
Size:	161.6 KB 
ID:	18806Click image for larger version. 

Name:	Visual2.jpg 
Views:	9 
Size:	79.1 KB 
ID:	18807

  3. #3
    KyleMac is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Nov 2014
    Posts
    10
    I did something very similar. Essentially you'd want to setup the filter on your new form based off the two criteria you are specifying.

    This is the form that opens when you double click on the text box:
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
            Me.MClmNum = Forms!frmClaimSearch.MClmNum.Text 'Copying the value from your record filter to the new form (MClmNum as an example)
            Me.MClmLoanNum = Forms!frmClaimSearch.MClmLoanNum.Text
            Forms!frmClaimSearch.MClmNum.Text = "" 'Clearing it if you used a separate text box to identify the record (I did, not sure if it's necessary)
            Forms!frmClaimSearch.MClmLoanNum.Text = ""
    
            Dim strMyFilter As String
            Dim lngLen As Long
    
            If Not IsNull(Me.MClmNum) Then
                strMyFilter = strMyFilter & "([MClmNum] = """ & Me.MClmNum & """) AND "
            End If
            If Not IsNull(Me.MClmLoanNum) Then
                strMyFilter = strMyFilter & "([MClmLoanNum] = """ & Me.MClmLoanNum & """)"
            End If
            
            lngLen = Len(strMyFilter)
            If lngLen <= 0 Then
                strMyFilter = ""
                Me.Filter = strMyFilter
                Me.FilterOn = True
                Exit Sub
            Else
                strMyFilter = Left$(strMyFilter, lngLen)
                Me.Filter = strMyFilter
                Me.FilterOn = True
            End If
    
         
    End Sub
    Last edited by KyleMac; 11-21-2014 at 03:16 PM. Reason: misread part of the question

  4. #4
    IncidentalProgrammer is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Aug 2014
    Location
    Texas
    Posts
    156
    Thanks, KyleMac!

    Forgive me, I am still VERY new to programming and Access. Could I potentially route that into a DoCmd.OpenForm on the search form? There are multiple ways to access these profile forms, so I'm worried that putting it on the profile forms' open event could interfere with opening from another path. Or would that not be the case? I could be wrong.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,896
    Consider instead of the Filter and FilterOn code:

    DoCmd.OpenForm "formname", , , strMyFilter
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2014, 07:42 PM
  2. Double click on listbox to open up form
    By EthanMoist in forum Forms
    Replies: 14
    Last Post: 05-21-2013, 02:10 PM
  3. On Double Click Open Form with two criteria
    By AndreasPanayiotou in forum Programming
    Replies: 3
    Last Post: 09-10-2012, 08:47 AM
  4. Click Event to create Records in two tables
    By mrfixit1170 in forum Forms
    Replies: 11
    Last Post: 10-20-2011, 12:01 PM
  5. Opening another form by double click
    By chrisjack001 in forum Access
    Replies: 1
    Last Post: 10-13-2010, 02:19 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