?
Solved

Show subform after cbo update

Posted on 2004-08-26
7
Medium Priority
?
319 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

770 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