Solved

Show subform after cbo update

Posted on 2004-08-26
7
314 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

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.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

806 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