Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

vba code hide/show userform monthlyview

Posted on 2013-01-09
12
Medium Priority
?
1,787 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 29

Expert Comment

by:IrogSinta
ID: 38761738
OnEnter
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 400 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 1600 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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

916 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