On Double Click

R

Ronnie

I have a form the shows a customer name and phone number. I would like to be
able to double click on the customer name and go to the main customer form
for that customer. I've tried to set up a macro to open the form and find
the record. It opens the form but does not find the record. Is there a way
I can do this?

Ronnie
 
O

Ofer

In the DoubleClick Event select code instead of macro, and enter this code to
open the form

Dim MyWhereCondition as String

MyWhereCondition = "[CustName field name] = '" & Me.[CustName fieldName in
the form] & "'"

Docmd.OpenForm "FormName",,,MyWhereCondition
 
R

Ronnie

Looks close, but I must be missing something in the translation. My form
name is "frm_CustomerContacts" and my field name is "InitLastName".
--
Ronnie


Ofer said:
In the DoubleClick Event select code instead of macro, and enter this code to
open the form

Dim MyWhereCondition as String

MyWhereCondition = "[CustName field name] = '" & Me.[CustName fieldName in
the form] & "'"

Docmd.OpenForm "FormName",,,MyWhereCondition

--
Please respond to the group if your question been answered or not, so other
can refer to it.
Thank you and Good luck



Ronnie said:
I have a form the shows a customer name and phone number. I would like to be
able to double click on the customer name and go to the main customer form
for that customer. I've tried to set up a macro to open the form and find
the record. It opens the form but does not find the record. Is there a way
I can do this?

Ronnie
 
S

Someone

Hi Ronnie

I'm not sure whether you're saying they're both forms or whether the one you
double-click on is a subform and whether the form name you gave in your
second post is the one you double-click on or the one that opens.

Anyway, shown below is the command to open the required form
(frm_CustomerContacts?) and the (in my example) subform you're calling the
command from. If you're not calling from a subform, amend the code as
required.

DoCmd.OpenForm "frm_CustomerContacts", , , "[InitLastName] =" &
Forms!frm_Main!frm_Main_Subform.Form!InitLastName

However, you must have a connection between the two forms (Link Master and
Link Child) in order for this to work.

M


Ronnie said:
Looks close, but I must be missing something in the translation. My form
name is "frm_CustomerContacts" and my field name is "InitLastName".
--
Ronnie


Ofer said:
In the DoubleClick Event select code instead of macro, and enter this
code to
open the form

Dim MyWhereCondition as String

MyWhereCondition = "[CustName field name] = '" & Me.[CustName fieldName
in
the form] & "'"

Docmd.OpenForm "FormName",,,MyWhereCondition

--
Please respond to the group if your question been answered or not, so
other
can refer to it.
Thank you and Good luck



Ronnie said:
I have a form the shows a customer name and phone number. I would like
to be
able to double click on the customer name and go to the main customer
form
for that customer. I've tried to set up a macro to open the form and
find
the record. It opens the form but does not find the record. Is there
a way
I can do this?

Ronnie
 
R

Ronnie

They are both forms. One is the main form. The other is a tabulated form
that looks up phone numbers tabbed by alphabet. I would like to double click
on the last name and pull up the main form from the Phone list form. Am I
able to set up a Master/child link even though it's not set up as a subform?
--
Ronnie


Someone said:
Hi Ronnie

I'm not sure whether you're saying they're both forms or whether the one you
double-click on is a subform and whether the form name you gave in your
second post is the one you double-click on or the one that opens.

Anyway, shown below is the command to open the required form
(frm_CustomerContacts?) and the (in my example) subform you're calling the
command from. If you're not calling from a subform, amend the code as
required.

DoCmd.OpenForm "frm_CustomerContacts", , , "[InitLastName] =" &
Forms!frm_Main!frm_Main_Subform.Form!InitLastName

However, you must have a connection between the two forms (Link Master and
Link Child) in order for this to work.

M


Ronnie said:
Looks close, but I must be missing something in the translation. My form
name is "frm_CustomerContacts" and my field name is "InitLastName".
--
Ronnie


Ofer said:
In the DoubleClick Event select code instead of macro, and enter this
code to
open the form

Dim MyWhereCondition as String

MyWhereCondition = "[CustName field name] = '" & Me.[CustName fieldName
in
the form] & "'"

Docmd.OpenForm "FormName",,,MyWhereCondition

--
Please respond to the group if your question been answered or not, so
other
can refer to it.
Thank you and Good luck



:

I have a form the shows a customer name and phone number. I would like
to be
able to double click on the customer name and go to the main customer
form
for that customer. I've tried to set up a macro to open the form and
find
the record. It opens the form but does not find the record. Is there
a way
I can do this?

Ronnie
 
S

Someone

Yes, you can.

The simplest way is to use the automatic button creator that comes with
Access. Part of the questions in the wizard asks if you wish to open the
form and display 'all records' or 'specific records'. Choose 'specific
records' and in the next screen, choose the option that links the main form
with the form you're opening.

Have a look at the created code thereafter and see if you can understand how
it works.

On a side note, is the info in the form you're opening in a separate table
to the main form? If so, have you set a relationship between the two
tables?

HTH
M

Ronnie said:
They are both forms. One is the main form. The other is a tabulated form
that looks up phone numbers tabbed by alphabet. I would like to double
click
on the last name and pull up the main form from the Phone list form. Am I
able to set up a Master/child link even though it's not set up as a
subform?
--
Ronnie


Someone said:
Hi Ronnie

I'm not sure whether you're saying they're both forms or whether the one
you
double-click on is a subform and whether the form name you gave in your
second post is the one you double-click on or the one that opens.

Anyway, shown below is the command to open the required form
(frm_CustomerContacts?) and the (in my example) subform you're calling
the
command from. If you're not calling from a subform, amend the code as
required.

DoCmd.OpenForm "frm_CustomerContacts", , , "[InitLastName] =" &
Forms!frm_Main!frm_Main_Subform.Form!InitLastName

However, you must have a connection between the two forms (Link Master
and
Link Child) in order for this to work.

M


Ronnie said:
Looks close, but I must be missing something in the translation. My
form
name is "frm_CustomerContacts" and my field name is "InitLastName".
--
Ronnie


:

In the DoubleClick Event select code instead of macro, and enter this
code to
open the form

Dim MyWhereCondition as String

MyWhereCondition = "[CustName field name] = '" & Me.[CustName
fieldName
in
the form] & "'"

Docmd.OpenForm "FormName",,,MyWhereCondition

--
Please respond to the group if your question been answered or not, so
other
can refer to it.
Thank you and Good luck



:

I have a form the shows a customer name and phone number. I would
like
to be
able to double click on the customer name and go to the main
customer
form
for that customer. I've tried to set up a macro to open the form
and
find
the record. It opens the form but does not find the record. Is
there
a way
I can do this?

Ronnie
 
Top