[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Show subform after cbo update

Posted on 2004-08-26
7
Medium Priority
?
321 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 750 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 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