Open a Form depending on Value in Lookup List

D

Dr. Momo

Hi,
I have a form listing all the patients in the DB and each patient is on one
service or another. I want to be able to double click on the service (a value
from a lookup list) and open the respective form correlating to which service
they are on.
For example:
Patient log Form:

John Smith, Hospital Service
Donna Sharp, Outpatient

I want to be able to click on the Service (ie, Hospital Service) and open
the Hospital Service Form where MR=MR.

Any ideas?
Thanks so much
 
M

Marshall Barton

Dr. Momo said:
I have a form listing all the patients in the DB and each patient is on one
service or another. I want to be able to double click on the service (a value
from a lookup list) and open the respective form correlating to which service
they are on.
For example:
Patient log Form:

John Smith, Hospital Service
Donna Sharp, Outpatient

I want to be able to click on the Service (ie, Hospital Service) and open
the Hospital Service Form where MR=MR.


I don't understand what you mean by "lookup list", but if
it's a combo box or simple list box, you can use the list's
double click event procedure to open the service form with a
filter to whatever you want:

DoCmd.OpenForm "Hospital Service", _
WhereCondition:= "MR=""" & Me.[the list] & """"
 
D

Dr. Momo

Thank you for your reply.
Acutally, it's not a combobox or lookuplist. Rather, it's a textbox wherein
you can choose a specific text value, that will correlate to the specific
form I want to open. So, each record(with different MR#s) might have a
different text value and will therefore require a different form to open.
Possible? Or is there another way?

Marshall Barton said:
Dr. Momo said:
I have a form listing all the patients in the DB and each patient is on one
service or another. I want to be able to double click on the service (a value
from a lookup list) and open the respective form correlating to which service
they are on.
For example:
Patient log Form:

John Smith, Hospital Service
Donna Sharp, Outpatient

I want to be able to click on the Service (ie, Hospital Service) and open
the Hospital Service Form where MR=MR.


I don't understand what you mean by "lookup list", but if
it's a combo box or simple list box, you can use the list's
double click event procedure to open the service form with a
filter to whatever you want:

DoCmd.OpenForm "Hospital Service", _
WhereCondition:= "MR=""" & Me.[the list] & """"
 
M

Marshall Barton

Dr. Momo said:
Acutally, it's not a combobox or lookuplist. Rather, it's a textbox wherein
you can choose a specific text value, that will correlate to the specific
form I want to open. So, each record(with different MR#s) might have a
different text value and will therefore require a different form to open.

I have no idea what you are trying to say here:
"it's a textbox wherein you can
choose a specific text value"

If the service specific form names are derived from the
names of the services, then that should not be a text box
with user typed values. It should be a combo box with
LimitToList set to yes so users can not enter an invalid
service name and make your program fail because there is no
form to open.

Anyway, it the service name in your "lookup list" is exactly
the same as the name of the related service form, try
something like:
DoCmd.OpenForm Me.[the service text/combobox]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top