I'm trying to create, in a form, a pop up where I can punch in two number to get a percentage. Say I want to know what percentage 5000 is of 25000. How would I do this and could you give me an example?
First put a button on the form from which you want to display the popup, with code like:
Code:
Private Sub CmdPopup_Click()
DoCmd.OpenForm ("Frm_Popup")
End Sub
adjust the names as necessary.
You will then need a new form (frm_popup) with three textboxes (TxtNumerator, TxtDenominator, and TxtPercent) as well as a button (CmdCalculate).
Right click on the button and create an event, and enter this code:
Code:
Private Sub CmdCalculate_Click()
If IsNull(TxtDenominator) Or TxtDenominator = 0 Then
MsgBox ("Please complete 'of:' field on this form")
Exit Sub
End If
TxtPercent = Format(TxtNumerator / TxtDenominator, "0.00%")
End Sub
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.