Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Vba code for double click
Pierre-Jean Tessier 
    
3 years ago
Hi everyone,
I made a button in VBA code to open a different form which takes a value from the subform and then displays it in the new form opened.

Down below is the code used:

Function Personnels_Select()
On Error GoTo Personnels_Select_Err

    With CodeContextObject
        DoCmd.OpenForm "RAI", acNormal, "", "[DOSSIER_RAI]=" & "'" & .Personnels_DossiersRAI.Form!DOSSIER_RAI & "'", , acNormal
    End With

Personnels_Select_Exit:
    Exit Function

Personnels_Select_Err:
    MsgBox Error$
    Resume Personnels_Select_Exit

End Function

Private Sub BtnSuivi_Selection_Click()
    Personnels_Select
End Sub

I also want to achieve the same result but without using the Button.

I want to be able to double click the field [DOSSIER_RAI] found on the subform so it opens a different form called "RAI" based on that particular field. So criteria is [DOSSIER_RAI]

I tried copying the button vba code but it's not working..
Any help would be appreciated!

Pjay
Pierre-Jean Tessier OP  @Reply  
    
3 years ago

Pierre-Jean Tessier OP  @Reply  
    
3 years ago

Kevin Yip  @Reply  
     
3 years ago
The expression below would be incorrect if your subform is Personnels_DossiersRAI:

    CodeContextObject.Personnels_DossiersRAI.Form!DOSSIER_RAI

If you run the line above in a subform's double-click event, then CodeContextObject will be pointing to the current active object, which is the subform.  So the line above essentially will become:

    Personnels_DossiersRAI.Personnels_DossiersRAI.Form!DOSSIER_RAI

which of course won't run.

To refer to DOSSIER_RAI on a subform from inside a subform's code, just refer to it as DOSSIER_RAI, or Me!DOSSIER_RAI.  Make that change on the subform's double-click event procedure, and the code should run.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/7/2026 3:46:45 AM. PLT: 0s