Solved

Show subform after cbo update

Posted on 2004-08-26
7
313 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Familiarize people with the process of utilizing SQL Server stored procedures 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 Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now