Darren
09-04-2007, 04:00 AM
Hi Captains
Need to code an error message ...
When my UserForm, opens the user must enter an amount in the Turnover TextBox Before he/she can continue on the UserForm.
Userform is called BasicTerms
This is the first Userform that opens on running the program
The Workbook code to open is as follows
Private Sub Workbook_Open()
'hide the workbook
Application.Visible = False
'display message
MsgBox "Welcome to Your Profit Wizard" & vbNewLine & _
vbNewLine & _
"Enter your Turnover"
'show userform
BasicTerms.Show False
End Sub
The TextBox on the BasicTerms Userform that is set to tab index of 0 is called txtTurnoverIncl.
txtTurnoverIncl is the Textbox that must be filled in before moving on to cmbRoyalty....
The code as the BasicTerms opens is as follows
Option Explicit
Private Sub txtTurnoverExcl_Change()
If txtRoyalty.Text <> "" Then
lblRoyaltcost.Caption = Format(CDbl(txtTurnoverExcl.Text) * _
CDbl(txtRoyalty.Text) / 100, "#,##0.00")
End If
End Sub
Private Sub txtRoyalty_Change()
If txtTurnoverExcl.Text <> "" Then
lblRoyaltcost.Caption = Format(CDbl(txtTurnoverExcl.Text) * _
CDbl(txtRoyalty.Text) / 100, "#,##0.00")
End If
End Sub
Private Sub cmbRoyalty_Change()
If lblTurnoverExcl.Caption <> "" Then
If cmbRoyalty.Value <> "" Then
lblRoyaltcost.Caption = Format(CDbl(lblTurnoverExcl.Caption) * _
Replace(cmbRoyalty.Value, "%", "") / 100, "#,##0.00")
End If
End If
End Sub
Private Sub CommandButton1_Click()
Hide
OverHeads.TextBox14.Text = BasicTerms.lblTurnoverExcl.Caption
OverHeads.Show
End Sub
Private Sub CommandButton2_Click()
Hide
TheBasicFormulas.Show
End Sub
Private Sub CommandButton3_Click()
Hide
SalesTaxCalc.Show
End Sub
Private Sub CommandButton4_Click()
Hide
PromoCalc.Show
End Sub
Private Sub CommandButton5_Click()
Me.PrintForm
End Sub
Private Sub CommandButton6_Click()
Hide
Summary.Show
End Sub
Private Sub CommandButton7_Click()
Hide
DailyControl.Show
End Sub
Private Sub txtTurnoverIncl_AfterUpdate()
With txtTurnoverIncl
.Text = Format(.Text, "#,##0.00")
End With
End Sub
Private Sub txtTurnoverIncl_Change()
With txtTurnoverIncl
If .Text = "" Then
lblT.Caption = ""
Else
lblT.Caption = Format(Round(.Text * 14 / 114, 2), "#,##0.00")
lblTurnoverExcl.Caption = Format(CDbl(.Text - .Text * 14 / 114), "#,##0.00")
End If
End With
End Sub
Private Sub UserForm_Initialize()
Dim i As Long
For i = 0 To 35
cmbRoyalty.AddItem Format(i / 100, "0%")
Next i
End Sub
I have attached an immage for more clarity
Thanks for your attention
Darren
South Africa
Need to code an error message ...
When my UserForm, opens the user must enter an amount in the Turnover TextBox Before he/she can continue on the UserForm.
Userform is called BasicTerms
This is the first Userform that opens on running the program
The Workbook code to open is as follows
Private Sub Workbook_Open()
'hide the workbook
Application.Visible = False
'display message
MsgBox "Welcome to Your Profit Wizard" & vbNewLine & _
vbNewLine & _
"Enter your Turnover"
'show userform
BasicTerms.Show False
End Sub
The TextBox on the BasicTerms Userform that is set to tab index of 0 is called txtTurnoverIncl.
txtTurnoverIncl is the Textbox that must be filled in before moving on to cmbRoyalty....
The code as the BasicTerms opens is as follows
Option Explicit
Private Sub txtTurnoverExcl_Change()
If txtRoyalty.Text <> "" Then
lblRoyaltcost.Caption = Format(CDbl(txtTurnoverExcl.Text) * _
CDbl(txtRoyalty.Text) / 100, "#,##0.00")
End If
End Sub
Private Sub txtRoyalty_Change()
If txtTurnoverExcl.Text <> "" Then
lblRoyaltcost.Caption = Format(CDbl(txtTurnoverExcl.Text) * _
CDbl(txtRoyalty.Text) / 100, "#,##0.00")
End If
End Sub
Private Sub cmbRoyalty_Change()
If lblTurnoverExcl.Caption <> "" Then
If cmbRoyalty.Value <> "" Then
lblRoyaltcost.Caption = Format(CDbl(lblTurnoverExcl.Caption) * _
Replace(cmbRoyalty.Value, "%", "") / 100, "#,##0.00")
End If
End If
End Sub
Private Sub CommandButton1_Click()
Hide
OverHeads.TextBox14.Text = BasicTerms.lblTurnoverExcl.Caption
OverHeads.Show
End Sub
Private Sub CommandButton2_Click()
Hide
TheBasicFormulas.Show
End Sub
Private Sub CommandButton3_Click()
Hide
SalesTaxCalc.Show
End Sub
Private Sub CommandButton4_Click()
Hide
PromoCalc.Show
End Sub
Private Sub CommandButton5_Click()
Me.PrintForm
End Sub
Private Sub CommandButton6_Click()
Hide
Summary.Show
End Sub
Private Sub CommandButton7_Click()
Hide
DailyControl.Show
End Sub
Private Sub txtTurnoverIncl_AfterUpdate()
With txtTurnoverIncl
.Text = Format(.Text, "#,##0.00")
End With
End Sub
Private Sub txtTurnoverIncl_Change()
With txtTurnoverIncl
If .Text = "" Then
lblT.Caption = ""
Else
lblT.Caption = Format(Round(.Text * 14 / 114, 2), "#,##0.00")
lblTurnoverExcl.Caption = Format(CDbl(.Text - .Text * 14 / 114), "#,##0.00")
End If
End With
End Sub
Private Sub UserForm_Initialize()
Dim i As Long
For i = 0 To 35
cmbRoyalty.AddItem Format(i / 100, "0%")
Next i
End Sub
I have attached an immage for more clarity
Thanks for your attention
Darren
South Africa