Solved

vba code hide/show userform monthlyview

Posted on 2013-01-09
12
1,545 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
  • 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
 
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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 29

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 29

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 29

Expert Comment

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

863 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

25 Experts available now in Live!

Get 1:1 Help Now