?
Solved

Populate a user form with a formula to calculate units per hr

Posted on 2015-02-09
7
Medium Priority
?
61 Views
Last Modified: 2015-02-10
From the time sheet form button, can the units per hour be calculated
StlFunction-Analisys-2015-v1f.xlsm
0
Comment
Question by:bjfulkerson
[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
  • 3
  • 3
7 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40600246
Don't understand the question.
0
 
LVL 10

Accepted Solution

by:
broro183 earned 2000 total points
ID: 40600459
hi,

Try adding the following code into the code behind the TimeSheetEntry Form module. This seems to hold up okay under some light testing.


Private Sub TxtTime_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Call CalcAndUpdateUPH_tbx
End Sub

Private Sub TxtUnits_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    Call CalcAndUpdateUPH_tbx
End Sub

Sub CalcAndUpdateUPH_tbx()
With Me
        'test that both fields are populated.
        If Len(.TxtTime.Value) * Len(.TxtUnits.Value) Then
            'validate that the entries are numeric.
            If IsNumeric(.TxtTime.Value) And IsNumeric(.TxtUnits.Value) Then
                .TxtUPH.Value = .TxtUnits.Value / .TxtTime.Value
            End If
        End If
    End With
End Sub

Open in new window


hth
Rob
0
 

Author Comment

by:bjfulkerson
ID: 40600466
Rob,
When you say behind, what does that mean?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Closing Comment

by:bjfulkerson
ID: 40600471
I added it to the top of the TimesheetEntry and it worked great!  Thanks for adding the explanations too!
0
 
LVL 10

Expert Comment

by:broro183
ID: 40600472
Sorry, I didn't word that very well.

It may just be my settings but when I double (left) click on the TimeSheetEntry item in the Forms folder within the Project Pane of the VBE, the result is that the Userform appears (on the right for me). To see the code relating to the Userform, I press [F7] or right click on on the item in the lefthand pane & choose "view code". This then shows the code relating to the userform eg "Private Sub UserForm_Initialize()" or "Private Sub Calendar1_Click()".

I consider this code as being "behind" the userform.

Rob
0
 

Author Comment

by:bjfulkerson
ID: 40600473
Got it . Thanks
0
 
LVL 10

Expert Comment

by:broro183
ID: 40600480
Awesome, I'm pleased I could help :-)

Now that it is a calculated field, I suggest changing the appearance of the textbox so that users can easily recognise that they don't need to populate it (eg "grey it out" by changing the backcolour to something like &H80000000&.
Or, if you want to get more complicated, you could allow users to enter values into any two of the three fields & then have the code calculate whichever one is the remaining empty field.

Rob
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
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 …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
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…

800 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