Solved

vba code hide/show userform monthlyview

Posted on 2013-01-09
12
1,704 Views
Last Modified: 2013-01-10
Could some one help me with VBA code?
In my userform, there are two textbox, txtSdate and txtEdate, the value is from two monthyviews MonthlyView1 and MonthlyView2
When I click txtSdate textbox, I want monthlyview1 show and monthlyview2 hide, data picked from monthyview1 is writen to txtSdate.
When I click txtEdate textbox, I want monthlyview2 show and monthlyview1 hide, data picked from monthyview2 is writen to txtSdate.

Please check the attached userform?
untitled.bmp
0
Comment
Question by:HemlockPrinters
[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
  • 5
  • 4
  • 3
12 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38761597
In the OnEnter event of txtSdate, add this:
Me.MonthlyView1.Visible=True
Me.MonthlyView2.Visible=False

Open in new window

In the OnEnter event of txtEdate, add this:
Me.MonthlyView1.Visible=False
Me.MonthlyView2.Visible=True

Open in new window

0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38761619
Add an OnChange for MonthView1 with this:
Me.txtSdate=Me.MonthView1.Value

Add an OnChange for MonthView2 with this:
Me.txtEdate=Me.MonthView2.Value
0
 

Author Comment

by:HemlockPrinters
ID: 38761727
thanks IrogSinta,
But how do you get OnEnter event?
0
Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

 
LVL 29

Expert Comment

by:IrogSinta
ID: 38761738
OnEnter
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 100 total points
ID: 38761748
Correction to my other post:
Private Sub MonthView1_Click()
    Me.txtSdate = MonthView1.Value
End Sub

Private Sub MonthView2_Click()
    Me.txtEdate = MonthView2.Value
End Sub

Open in new window

0
 

Author Comment

by:HemlockPrinters
ID: 38761810
I am using excel 2003 UserForm, I can't find property sheet as you showed
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38761861
Sorry about that, I thought you were using Access.  In that case, just paste this code in your form's code view:
Private Sub MonthView1_Click()
    Me.txtSdate.Value = MonthView1.Value
End Sub

Private Sub MonthView2_Click()
    Me.txtEdate.Value = MonthView2.Value
End Sub

Private Sub txtSdate_Enter()
    Me.MonthView1.Visible = True
    Me.MonthView2.Visible = False
End Sub

Private Sub txtEdate_Enter()
    Me.MonthView1.Visible = False
    Me.MonthView2.Visible = True
End Sub

Open in new window

0
 
LVL 31

Accepted Solution

by:
gowflow earned 400 total points
ID: 38762727
I tried to replicate your issue and noticed a problem when it comes to visible property of the monthview control. don't know if you had this problem the code proposed is fine but clicking on the textbox would not appear the control.

Anyway, Try this version make sure your macroes are enabled and activate the button in sheet1 and try the dates.

I has to insert the monthview control in a frame and hide/show the frame so it worked correctly.

gowflow
DateInput.xls
0
 

Author Comment

by:HemlockPrinters
ID: 38764105
Thhanks, it works. The problem is after I click both text boxs, the monthviews all disapear. When I click in text box, monthviw doesn' t show up.
0
 
LVL 31

Expert Comment

by:gowflow
ID: 38764274
yes It did here the same this is why I had to go the frame route. Not sure I understand your message though. Is it working now ???
gowflow
0
 

Author Comment

by:HemlockPrinters
ID: 38764394
Thanks, it is working withing frame.
0
 
LVL 31

Expert Comment

by:gowflow
ID: 38764442
Gr8 glad we could help out.
gowflow
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

626 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