Solved

Show subform after cbo update

Posted on 2004-08-26
7
315 Views
Last Modified: 2012-05-05
Hello,

I am working in a form that has three subforms that I want to only be shown if the appropriate value is selected in a combobox.  The cbo is a lookup field tied to a table.  Right now there are only three records "Correspondnece," Scheduling Request," and "Memorandum."  When a user selects an item from the dropdown, I'd like it to show the corresponding form.

I tried this, with no luck.

Private Sub DocTypeID_AfterUpdate()
If DocTypeID.Value = "Correspondence" Then
[Forms]![frmExecSecRecordEntry]![frmCorSub].Visible = True
End If


I was going to continue with the three options.  Any ideas?
0
Comment
Question by:mattturley
  • 3
  • 2
  • 2
7 Comments
 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11909301
The above should work if frmCorSub is the name of the subform *control*, not the subform itself. To check the subform control name, click on the subform in design view and check in the Properties window for the Name property (in the Other page). You must, of course, set the visible option to False if the combo box does not contain the correct value. The easiest way is probably to hide all three first and then only set the one you want to show.
0
 
LVL 1

Accepted Solution

by:
ClydeDoggie earned 250 total points
ID: 11909328
First, when you say 'no luck' do you mean that the correct subform didn't appear? If this is the case you need to see what the combo box value actually is after the update. You could throw up a messagebox to show you. You could have more than one column in your combo box and you are actually getting the value from a different column (the BoundColumn property). Either that or you don't have the same spelling in your code and lookup table.
Second, just as a performance tip, if you are only going to have one subform active and visible at a time I would use one subform control and just change its source. Loading subforms is relatively resource intensive.
Let me know if this doesn't help.
0
 

Author Comment

by:mattturley
ID: 11909352
frmCorSub is the name of teh subform.

I would just change the source, but the subforms are DRASTICALLY different... could go a different route and open a form that launches another form, but I don't want to do that.
0
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
LVL 41

Expert Comment

by:shanesuebsahakarn
ID: 11909360
Change frmCorSub to the name of the subform control in that case, and it should work.
0
 

Author Comment

by:mattturley
ID: 11909377
I checked to see what the value was after update.  It was the primary key value (an auto number field) of the table that lookup was based upon.  I wouldn't have thought about that without "ClydeDoggie" suggesting to check for it.

I changed my vba to ...

If DocTypeID.Value = "1" Then
[Forms]![frmExecSecRecordEntry]![frmCorSub].Visible = True

End If

Now the subform shows up when I select the value in the cbo.

Thanks.
0
 
LVL 1

Expert Comment

by:ClydeDoggie
ID: 11909417
Glad you were able to solve your problem.
Just as a final note, you say you don't want to change the subform controls source because the subforms are drastically different - you still would use three forms (as subforms), but would only have one subform Control (a host container). You then load the appropriate form into this control after update of your combobox.

CD
0
 

Author Comment

by:mattturley
ID: 11909427
hmmm... I think I'll have to sleep before thinking about that too much.  Long Day.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question