UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
2 Pages V  1 2 >  (Go to first unread post)
   Reply to this topicStart new topic
> Double Click A Datasheet Record And Open Form, Access 2013    
 
   
krosal
post May 27 2020, 07:52 PM
Post#1



Posts: 65
Joined: 22-October 18



I have a subform that is in datasheet view in the main form. The subform is based off of a query and I would like to double-click on one of the cells and have it open 'another form' that shows the record. I do already have the form created and is based off of the records in the query, but it always opens up to the first record in the datasheet. I've tried many different approaches, but to no success.

For instance; If I double-click on phone, it opens that record.


Thank you,
This post has been edited by krosal: May 27 2020, 07:56 PM
Go to the top of the page
 
RJD
post May 27 2020, 08:07 PM
Post#2


UtterAccess VIP
Posts: 10,596
Joined: 25-October 10
From: Gulf South USA


Hi:
QUOTE
I've tried many different approaches, but to no success.

Hard to know what that means, what you have tried and what "no success" actually means operationally.

You may actually be very close to a solution, but we won't know that. Could you post the db (at least a cutdown db with relevant objects, no sensitive data, zipped)? I think seeing how the db is working now should lead to a quicker resolution for you.

Looking forward to seeing your db ...

HTH
Joe

--------------------
"Each problem that I solved became a rule, which served afterwards to solve other problems."
"You just keep pushing. You just keep pushing. I made every mistake that could be made. But I just kept pushing."

Rene Descartes 1596-1650 (Mathematician and Philosopher)
Go to the top of the page
 
June7
post May 27 2020, 08:12 PM
Post#3



Posts: 1,533
Joined: 25-January 16
From: The Great Land


AFAIK, have to set focus to record via Record Selector on left side and code in form DblClick event. That's what I do.

This post has been edited by June7: May 27 2020, 08:12 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
Go to the top of the page
 
projecttoday
post May 27 2020, 08:58 PM
Post#4


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


Use the form's on double click event. Open the form using the field that identifies the record you want:

Docmd.OpenForm "form",,,"[IDfield] = " & Me.IDfield

--------------------
Robert Crouser
Go to the top of the page
 
krosal
post May 27 2020, 09:19 PM
Post#5



Posts: 65
Joined: 22-October 18



That did work perfect for the ID field, it opens the correct record. If I click on the 'Model' field, how would that be coded.

This is what I put in for the ID field and it worked.

DoCmd.OpenForm "frmChanges_sub", , , "[ID] = " & Me.ID

I put it in the other fields and that worked perfect!


Thank you!
This post has been edited by krosal: May 27 2020, 09:22 PM
Go to the top of the page
 
projecttoday
post May 28 2020, 01:39 AM
Post#6


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


Did you put that statement in the on click event of every field? If you put it in the on click event of the form you just have to put it once. Of course the user has to click at the side of the line. Won't work if you click on the fields. But no code on every field.

--------------------
Robert Crouser
Go to the top of the page
 
krosal
post May 28 2020, 05:08 AM
Post#7



Posts: 65
Joined: 22-October 18



Yes, I did put it in the double-click event for each field in the subform. When I didn't the only time it would open is when I clicked on an ID field.
This post has been edited by krosal: May 28 2020, 05:14 AM
Go to the top of the page
 
projecttoday
post May 28 2020, 06:54 AM
Post#8


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


If you put it in the form's on double click event, not the id field's on double click event, then the form will open when the user double clicks the area at the left of each line, the left-hand margin as get you call it. You can instruct the user that's where they are supposed to click. This is a common practice and is acceptable to many. You can put "V click" at the top with a V pointing at where they are supposed to click. If you want the whole line to be click-active, you have to add the code to each individual field. It's a matter of preference.

--------------------
Robert Crouser
Go to the top of the page
 
cheekybuddha
post May 28 2020, 07:03 AM
Post#9


UtterAccess Moderator
Posts: 13,046
Joined: 6-December 03
From: Telegraph Hill


Hi,

Try and see if it works this way.

In your form's module, move the code from the DoubleClick event of your ID field in to its own function:
CODE
Public Function OpenChanges()

  DoCmd.OpenForm "frmChanges_sub", , , "[ID] = " & Me.ID

End Function


Then, with your form in Design View, select all the textboxes (ID, Model, etc ...).

With them all selected, go to the events tab in the Properties sheet.

In the DoubleClick event put:
CODE
=[Form].OpenChanges()


Then you should be able to double-click on any of the fields in datasheet view and open the form.

hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
FrankRuperto
post May 28 2020, 09:46 AM
Post#10



Posts: 1,112
Joined: 21-September 14
From: Tampa, Florida USA


When clicking on any field in the datasheet, I suggest you open the form in modal mode. This way it opens as a popup. This is especially useful when drilling down multiple master/detail levels. Modal will not allow you open other forms or click on anything outside of the popup until you close it.

CODE
Private Function OnClickOpenDetailForm()
   gReturnToFormName = "frmMaster"
   Forms!frmMaster!MasterSource = "master"
  
   DoCmd.OpenForm "frmDetail", WindowMode:=acDialog, OpenArgs:=Me.PrimaryFieldID
  
End Function

https://docs.microsoft.com/en-us/office/vba...ss.acwindowmode
https://docs.microsoft.com/en-us/office/vba....docmd.openform
This post has been edited by FrankRuperto: May 28 2020, 10:12 AM

--------------------
Currently supporting pawnbrokers that use my store management system developed with Access 2010 on Windows7. Experienced with Informix, Oracle & PostgreSQL db's.
Go to the top of the page
 
projecttoday
post May 28 2020, 10:13 AM
Post#11


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


I agree a popup is a good option. Another approach on a datasheet is nesting the subform directly on the datasheet. When you do this you get a plus sign that you can click on to display the subform.

--------------------
Robert Crouser
Go to the top of the page
 
krosal
post May 28 2020, 07:04 PM
Post#12



Posts: 65
Joined: 22-October 18



I will put together a stripped down database just to make sure we're all on the same page. Please check back after Saturday morning to take a look at what I'm trying to accomplish and then a best judgement can be made from that.

I will work on removing any information that could be considered private.

I do really appreciate everyone's help and time.

Thank you,
Go to the top of the page
 
krosal
post May 29 2020, 05:21 AM
Post#13



Posts: 65
Joined: 22-October 18



I have attached my database. The subform in question is the subform that is created from qryChages_Sub nd when I double click a record it opens frmChanges_Summary.

The way it is now when I double click any of the records, it not opens the form frmChanges_Summary.

Please see the attached

Thank you,
Go to the top of the page
 
projecttoday
post May 29 2020, 05:46 AM
Post#14


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


How to display the code?

--------------------
Robert Crouser
Go to the top of the page
 
krosal
post May 29 2020, 06:12 PM
Post#15



Posts: 65
Joined: 22-October 18



I suppose that would be good to know.

If you open the form frmSearchChanges and then click any of the fields in the subform where the ID is highlighted, you can then get to the code.

I also noticed that after changing a form name, the button for 'Open Matching' wasn't working.

I have attached the fixed database.

Thank you,
This post has been edited by krosal: May 29 2020, 06:26 PM
Go to the top of the page
 
projecttoday
post May 29 2020, 09:52 PM
Post#16


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


You have to go into design view to do that. How do you get to design view?

--------------------
Robert Crouser
Go to the top of the page
 
krosal
post May 30 2020, 06:05 AM
Post#17



Posts: 65
Joined: 22-October 18



Upon opening the database hold down the shift key to get to the design structure of the database. When you see all the tables and forms, right click on the frmSearchChanges and select Design View. Once here you will see the design of the form.

Are you having a problem getting to the design view of the database?
Go to the top of the page
 
projecttoday
post May 30 2020, 11:29 AM
Post#18


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


Sorry, I forgot to hold the shift key.

Is this the code you're talking about? It seems to work fine. What would you like to do to it?

CODE
Private Sub Assigned_User_DblClick(Cancel As Integer)

    DoCmd.OpenForm "frmChanges_Summary", , , "[ID] = " & Me.ID

End Sub

Private Sub Category_DblClick(Cancel As Integer)

    DoCmd.OpenForm "frmChanges_Summary", , , "[ID] = " & Me.ID

End Sub

Private Sub Changes_Made_DblClick(Cancel As Integer)

    DoCmd.OpenForm "frmChanges_Summary", , , "[ID] = " & Me.ID

End Sub

Private Sub DateTime_DblClick(Cancel As Integer)

    DoCmd.OpenForm "frmChanges_Summary", , , "[ID] = " & Me.ID

End Sub


--------------------
Robert Crouser
Go to the top of the page
 
projecttoday
post May 30 2020, 11:37 AM
Post#19


UtterAccess VIP
Posts: 12,404
Joined: 10-February 04
From: South Charleston, WV


Code for Open_Matching. This opens frmChanges_Summary.

CODE
Private Sub cmdOpenMatching_Click()
'Open a form for displaying the selected records
'Set cDetailFormName to the name of your form


    On Error GoTo Proc_Err
    
    Const cDetailFormName As String = "frmChanges_Summary" '!!!!! Change this to the name of your form!
    
    Dim strFilter As String 'Combine filters applied through the filtering control AND the form filter - note, still an issue with form filtering on top 1000
    
    If clsFrmSearch.CurrentFilter <> "" Then strFilter = clsFrmSearch.CurrentFilter
    If Me.Form.Controls(strSubForm).Form.Filter <> "" Then
        If strFilter = "" Then
            strFilter = Replace("  (" & Me.Form.Controls(strSubForm).Form.Filter & ")", "[sbfrmSearchNotification].", "", 1)
        Else
            strFilter = strFilter & Replace(" AND (" & Me.Form.Controls(strSubForm).Form.Filter & ")", "[sbfrmSearchNotification].", "", 1)
        End If
    End If
    

    DoCmd.OpenForm cDetailFormName, acNormal, , strFilter 'clsFrmSearch.CurrentFilter & Replace(" AND (" & Me.Form.Controls(strSubForm).Form.Filter & ")", "[sbfrmSearchNotification].", "", 1)
    If strFilter = "" And Forms(cDetailFormName).Filter <> "" Then Forms(cDetailFormName).Filter = ""
    
Proc_Exit:
    Exit Sub
Proc_Err:
    StandardErrors Err, True
    Resume Proc_Exit
End Sub

--------------------
Robert Crouser
Go to the top of the page
 
krosal
post May 31 2020, 07:17 AM
Post#20



Posts: 65
Joined: 22-October 18



Yes, the code you've provide for me was working fine, Thank you for that. I was really just responding to the messages that were being questioned and to give everyone that supported me in this thread the full details on the database so a determination on the best approach for my circumstance with the datasheet could be made. Also to help me understand the best approach for my future database projects.

I thank you for all the time that everyone puts in on this UtterAccess website. All the support that I've received in the past dozen years or so on this website has been extremely helpful. You are all very gifted in what you can do.

Thank you,
Sincerely,

Kelly
Go to the top of the page
 
2 Pages V  1 2 >


Custom Search


RSSSearch   Top   Lo-Fi    13th July 2020 - 06:59 AM