Solved

vba code hide/show userform monthlyview

Posted on 2013-01-09
12
1,564 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Dynamic Chart Range 13 36
If a cell in a range equals "YES" return specific Test. 4 32
And OR formula 5 22
formula how to get the number incrementor? 3 23
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

778 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