Solved

vba code hide/show userform monthlyview

Posted on 2013-01-09
12
1,512 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
Comment Utility
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
Comment Utility
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
Comment Utility
thanks IrogSinta,
But how do you get OnEnter event?
0
 
LVL 29

Expert Comment

by:IrogSinta
Comment Utility
OnEnter
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 100 total points
Comment Utility
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
Comment Utility
I am using excel 2003 UserForm, I can't find property sheet as you showed
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 29

Expert Comment

by:IrogSinta
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks, it is working withing frame.
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
Gr8 glad we could help out.
gowflow
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This very simple solution applies to a narrow cross-section of the "needs to close" variety. In this case, the full message in Event Viewer was in applog, Event ID 1000: Faulting application iexplore.exe, version 8.0.6001.18702, faulting module …
The canonical version of this article is on my web site here: http://iconoun.com/articles/collisions/ A companion presentation is available here: http://iconoun.com/articles/collisions/Unicode_Presentation.pdf
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

743 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

10 Experts available now in Live!

Get 1:1 Help Now