Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-29-2019, 10:48 PM   #1
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Double Click event to open to specific record

Ok, I am having a hard time getting this to work. I have seen numerous posts all over the Internet stating to use the below code. However when I place this code onto the Double click event, it opens to a blank record, but if I double click it again while the one form is still open, it will then display the correct record. Almost like I have to quad click it, which doesn't make no sense. Any suggestions?

Private Sub JobID_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmAdminOrders", , , "[JobID] = " & Me.JobID
End Sub

I have tried different variations of this code as well, but still no luck. As far as I can see the relationship links are setup correctly to use JobID as the link PK.

Thank you for any suggestions and help.

T. McConnell is offline   Reply With Quote
Old 06-29-2019, 11:06 PM   #2
JHB
Have been here a while
 
Join Date: Jun 2012
Location: In the south of Denmark (Jutland), near the German border.
Posts: 7,674
Thanks: 2
Thanked 2,060 Times in 2,015 Posts
JHB has a spectacular aura about JHB has a spectacular aura about
Re: Double Click event to open to specific record

In which form do you've the code when you click it first time and also the second time?
If you can't get it post your database with some sample data, zip it!
__________________
If the above post has helped you, why not take the time to say thank you, by pressing the "Thumbs up."
JHB is offline   Reply With Quote
The Following User Says Thank You to JHB For This Useful Post:
T. McConnell (06-30-2019)
Old 06-29-2019, 11:20 PM   #3
Gasman
Enthusiastic Amateur
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 3,672
Thanks: 398
Thanked 637 Times in 618 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Double Click event to open to specific record

It will do that if the record with JobID does not exist.?

I worked around that issue by passing in the ID as OpenArgs as well

DoCmd.OpenForm "frmSubmitterClient", , , "ClientID = " & Me.ClientID, , acDialog, Me.ClientID

In the called form
Code:
Private Sub Form_Current()
If Me.NewRecord Then
    Me.ClientID = Me.OpenArgs
End If
End Sub
HTH

__________________
Access novice. Sometimes trying to give something back.
Access 2007


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Gasman is offline   Reply With Quote
The Following User Says Thank You to Gasman For This Useful Post:
T. McConnell (06-30-2019)
Old 06-30-2019, 11:42 AM   #4
T. McConnell
Newly Registered User
 
Join Date: Jun 2019
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
T. McConnell is on a distinguished road
Re: Double Click event to open to specific record

Thank you all for the help, shortly after posting this (which was way too early in the AM lol) I was able to get it to work. Below is what I was able to get to work using some code from other sources as well. Maybe it may help someone down the road also.

Private Sub JobID_Click() '<-- I decided to go with a single click instead of a double click method, but it worked on the double click as well.
Dim rs As Object
Dim OpenAlert As Long

'Set variable to the current record
OpenAlert = Me.JobID 'Change JobID to your field
'open the new form
DoCmd.OpenForm "frmAdminOrders"

'Go to the selected record
Set rs = Forms!frmAdminOrders.RecordsetClone
rs.FindFirst "JobID = " & OpenAlert

'Optional lines shown below can be included if there's a chance the record won't exist in the form being opened
If rs.NoMatch Then 'optional - if no match, go to a new record
DoCmd.GoToRecord acForm, "frmAdminOrders", acNewRec 'optional
Else 'optional
Forms!frmAdminOrders.Bookmark = rs.Bookmark
End If 'optional
Set rs = Nothing
End Sub

Thanks again!


Last edited by T. McConnell; 06-30-2019 at 11:43 AM. Reason: Changed some verbiage
T. McConnell is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Double Click Event to Open Form showing Specific Subform samjh Forms 0 01-30-2013 06:07 AM
Subform double click record event Ben5505 Forms 6 06-15-2012 01:34 PM
Double Click on Record Selector Event MooreCreations Modules & VBA 4 09-10-2008 11:17 AM
How to open a form from a double-click event M0E-lnx Forms 4 09-09-2008 02:25 PM
Double Click Event but Wrong Record Displays cindyareed Forms 15 05-15-2002 09:16 AM




All times are GMT -8. The time now is 02:32 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World