Dbl Click to Open Customer Details

KLahvic01

Registered User.
Local time
Today, 17:35
Joined
May 3, 2012
Messages
80
I have a Form named frmCustomerList which is a datasheet view form and what I am trying to do is when I would like to edit a particular customer, I would like to double click on the CustomerID field and have it pull up in the frmCustomers so it can be edited. I found some code that seems like it should work, but when I double click the ID it opens frmCustomers but to no record. Here is the code I put on the dbl Click event of the CustomerID field:

Code:
Const FORMNAME = "frmCustomers"
    Dim ctrl As Control
    Dim strCriteria As String
On Error GoTo Err_Handler
    Set ctrl = Me.ActiveControl
    strCriteria = "[CustomerID] = """ & ctrl & """"
    DoCmd.OpenForm "frmCustomers", WhereCondition:=strCriteria
Exit_Here:
    Exit Sub
Err_Handler:
    MsgBox Err.Description, vbExclamation, "Error"
    Resume Exit_Here

Is there something I need to do on the frmCustomers side to understand what the CustomerID event is trying to do? Any help would be appreciated.

KJ
 
I don't think you need the quotes if [CustomerID] is a number. Try:
strCriteria = "[CustomerID] = " & ctrl
 
Ok, I tried ammending the code as you stated, but the frmCustomers still opens but is blank. I am missing something here.
 
what happens if you change

strCriteria = "[CustomerID] = " & ctrl

to

strCriteria = "[CustomerID] = " & ctrl.Value
 
Is the "Data Entry" property of the form being opened set to "No".
 
The form still comes up blank.

Is there anything that I need to do with the form I want to open in order for it to recognize the CustomerID being passed by the dbl Click event?
 
The form still comes up blank.

Is there anything that I need to do with the form I want to open in order for it to recognize the CustomerID being passed by the dbl Click event?

As Bob Fitz wrote - Is the Data Entry property of the form set to NO like it should be or is it set to YES which would cause it to not have any records displayed.
 
How do you normally open that "Customer Detail" form?
Say there is a drop down of Customers, and when you select one, it goes to that Customer Detail. Do you have anything like that?

Because if you do, just copy the code from the drop down Click event (or wherever the code is) and paste it in the Double Click event for the Customer ID data field on the datasheet.

I use this "drill down" method all the time.
There are some technicalities that would take a lot of explaining for me - but if you have any control that will open the form the way you want to see it, look at THAT code and then adapt it for your needs.

Sorry I can't be more specific - as I said, I do have a method but it may not agree with your current archetechture anyway.
 
It looks like what has happened is my record source was not set right. It works now, but the caveat to all of that is my customer notes entry needs to now be added to the form as a subform since I have it set to date stamp all of the notes as they are entered. Minor setback, but worth it in the end.

Thank you all for your help!
 

Users who are viewing this thread

Back
Top Bottom