Opening a Form based off of a Double Click event on a Report

Okibi07

Registered User.
Local time
Yesterday, 22:29
Joined
Aug 15, 2013
Messages
13
Hi all,

I'm pretty new to Access, so excuse if this is a weird or backward question. I have searched the forums and havn't really found something specific to my problem, so help would be appreciated.

I have a main Form "Client" that shows details such as Representatives, phone numbers, status, etc. I also have a main report "CRM" that is a nicer summarized table version of all of my Client form entries.

The "CRM" form will be used by others in my office to see what clients we are contacting, etc. What I want to be able to do is have someone open the CRM form first. If they want to see even more specific info (not everything is included in the report, as that would be too messy), I want them to be able to double click the Client's name on the report and be taking to the corresponding entry on the Client form that shows more details.

Right now my code for the Report which is not working is the following:

Private Sub Client_Name_DblClick()
'double click on a client name in the report​
DoCmd.OpenForm "Client", acNormal, , "[Client_Name]='" & [Client_Name]
'this should open the Client Form to the record of the same client that was double clicked on the report​
End Sub

Any and all help is much appreciated!
 
Thanks for that Paul, that does help me understand a bit more.

Unfortunately I am still getting an error message. What I think is going wrong is that on the Report, I am clicking "Client Name". I want the DoCmd to open the form based on the report's "Client Name" which is also the same "Client Name" on the form. I think the issue is that Access doesn't know that these "Client Name"s are one and the same. Does that make sense?
Any advice how to fix?
 
What is your code now, because it wasn't complete before?
 
It's essentially the same as before, with slight changes to reflect that I'm basing it off text and the "FieldName" has been updated to reflect my Client Form's record source properly.

Private Sub Client_Name_DblClick()
DoCmd.OpenForm "Client", acNormal, , "Client = '" & Me.Client_Name & "'"
End Sub

Still getting same error message!

Attaching stripped down version for you to pick over. :)
 

Attachments

Last edited:
Error message:

The expression On Dbl Click you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.
*The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
* There may have been an error evaluating the function, event, or macro

This error occurs when an event has failed to run because MS Access cannot evaluate the location of the logic for the event.
 
You have 2 (or more) procedures with the same name: Client_Name_DblClick()
Remove all of them except one.
 
For starters, the code is different than posted. I think you still have a corrupted control or something, but I was able to get rid if it by:

1) copy code:

DoCmd.OpenForm "Client", acNormal, , "[Client name] = '" & Me.[Client Name] & "'"

2) Delete all code on that report (if the real version has more, just that whole bit, procedure lines and all)

3) save form

4) edit form, put code back into event
 
I don't really know what you mean - I only see once in all my VBA where I have "Client_Name_DblClick"

Sorry, still learning Access language here, really appreciate your help!
 
Hi Paul,

Should I redo the code in the Client Form's VBA, or continue putting it in the CRM Report's VBA?

Thanks!
 
It would still be in the report's code, I think the association between the code and the event just needs to be recreated. By the way, I didn't see 2 procedures with the same name either.
 
I don't really know what you mean - I only see once in all my VBA where I have "Client_Name_DblClick"

Sorry, still learning Access language here, really appreciate your help!

I was able to replicate the exact error message by creating a copy for the DoubleClick procedure in a test database.
So, look again or, better, select the entire name of procedure then press CTRL+F.
Then click Next.
 
Ok, deleted, closed the program, copy and pasted your code and suggestions, still getting same error message.

Not sure what else I'm screwing up! Thanks so much for all your help with my database!
 

Attachments

Try this, I just followed the steps I outlined and it worked fine.

mihail,not saying that wouldn't cause the same error, but I didn't see a duplicate in the file posted to this thread.
 

Attachments

Woooo Paul you are my super hero!!! :D

I guess it was just the "integer" addition that made it work? Access is weird.

Thanks x1 million for this!
 
Change the control name from Client Name in ClientName.
Then define the double click procedure for this "new" control.

And keep in mind forever: Do not use spaces in the names (field names, control names, table names, query names etc etc.
 
Hi Paul.
Just try to compile the code and will see what happen.
I never saw this error until now, so I've learned something new here. Thank you, Okibi ! :)
 
The "integer" bit was added by Access; if you didn't have it, how did you create the code? I don't think it was a problem of duplication, rather one of association. I deleted 1 instance of the code and then re-added it. If there was duplication, I would still have gotten the error.
 

Users who are viewing this thread

Back
Top Bottom