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 
Open Form by Combo
Nancy Proctor 
    
5 years ago
Hi Richard,

I'm trying to figure out how I can open a specific form based on a selection I make from a combo box.

I'm thinking I can somehow build a macro using the IIf function somehow, but I haven't been able to figure it out and it's probably better to write it in code builder using VBA.  Do you have any prerecorded lessons that I can purchase that explain how to do this?

Richard Rost  @Reply  
           
5 years ago
How is the form that's opened determined? What are you selecting in the combo box? If it's just that you want a list of forms in the combo box, then that's easy. Otherwise, yes, I would do what you suggest: make an IF THEN block (or a SELECT CASE statement) in VBA and open the appropriate form. Tell me exactly how this form is chosen and I'll help you out. I haven't done anything like this in any of my classes, but it would make a cool TechHelp video.
Nancy Proctor OP  @Reply  
    
5 years ago
In my table [TBL_Patients], I have a combo box field named [Cover_RX].  For context, Cover Rx is a medication discount program.  The combo box selections for that field is either "Yes" or "No".  Basically, I document if each patient enrolled into the discount program or not.  On the after update event, if "Yes" is selected, I'd like the popup form [FRM_Cover_RX_Yes] to open.  That form gets it data from the table [TBL_Cover_RX_Yes].  There are several fields in that table allowing me to document information that a pharmacy would need so the patient could get his/her discount on meds.  If "No" is selected, the popup form [FRM_Cover_RX_No] would open with a field allowing me to document why the patient does not have this discount.
I use this in the "where condition =" line in my macro to ensure that info is documented on the right patient: ="[Patient ID]=" & [Patient ID]
Richard Rost  @Reply  
           
5 years ago
Yeah this would be a simple AfterUpdate event:

If ComboValue="Yes" then
   DoCmd.OpenForm "Form1"
else
   DoCmd.OpenForm "Form2"
end if


Assuming your combo box is storing the text value "Yes" and not an actual Yes/No field, which case you'd change it to True/False. Is this data stored in the same table as the patient info, or is it a different table? I ask because you might be better off just showing/hiding relevant fields instead of opening two entirely different forms.
Nancy Proctor OP  @Reply  
    
5 years ago
my combo box is actually storing the words "Yes" and "No".  I prefer that over a check box (True/False).  The Yes/No is in the same table as the patient info.

The Cover Rx details is in it's own table

The reason for no Cover Rx is in it's own table.

So, 3 tables total.  I've always been under the impression that it's not a good idea to have a table with a bunch of empty fields so that's why I created 2 different tables for the cover rx details describing the yes/no.  not sure if that's the best approach.

In my relationships, the patient table and the cover rx yes table are connected via a one to many and the patient table and the cover rx no table are connected via a one to many.
Richard Rost  @Reply  
           
5 years ago
The way you're doing it is fine. If it's just ONE empty field, or a couple, that's not a big deal. For example, let's say you have an OrderType which is either Online or Shipped. If someone selects Shipped you could just hide (Visible=FALSE) the Address fields. Sure, you'd have a blank couple of fields for each customer, but that's not too big of a deal. If your "No Cover Rx" for example is just ONE field, there's no reason to have a separate table for it. Just my opinion though. If what you have works, keep it.
Richard Rost  @Reply  
           
5 years ago
And of course, I've got TONS of Developer lessons available to teach you programming. If you just want a quick intro, start here: Intro to VBA. It's free.
Nancy Proctor OP  @Reply  
    
5 years ago
I wasn't sure how to incorporate the where condition "="[Patient ID]=" & [Patient ID]" into the code that you wrote, so I created a macro that mirrored what you wrote so I could add the above where condition.  yes...it's time I take I start learning VBA.

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/6/2026 11:37:15 AM. PLT: 1s