Good day Guys
This is my first post as a member (and a guy that just discovered forms) so my humble apologies if I am doing it wrong.
So here goes:
Ive got a Userform (Tax_Year_Details) that asks the User to select TAX YEAR DATE from a combobox(works perfect) and then to type opening odometer from a textbox1 and closing odometer from textbox2 and then finally total Business Kilometer in textbox4. All of these three textboxes are defined as
Once proceeding to click on the OK button it need to do a few checks and if there are errors a msgbox should give a describtion.Private Sub TextBox1_Change() Range("b8").Value = TextBox1 End sub Private Sub TextBox2_Change() Range("b9").Value = TextBox2 End Sub Private Sub TextBox4_Change() Range("b14").Value = TextBox4 End Sub
.... example Textbox2 can not be less in value than textbox1. E.G Opening reading is 5000km (textbox1) and Closing reading 4000km(textbox2) = msgbox " Closing is less than opening - Re-enter"
and
....example textbox3 can not be more than the difference of textbox2-textbox1. E.G. Traveled 2000km this year but opening reading was on 1000km and closing reading was on 1400km, = msgbox " Kilometers traveled is greater than kilometers from Opening and Closing specified"
Private Sub Tax_year_OK_button_Click() ' First test that closing isnt less than opening If Range("B9") < Range("B8") Then MsgBox "CLOSING KILOMETERS IS LESS THAN OPENING KILOMTERS - Change Closing Kilometers" TAX_Year_date.Show 'Second test if traveled in year for business is greater than Cell B9 - and cell B8 ElseIf Range("B14") < Range("B13") Then MsgBox "TOTAL KILOMETERS TRAVELED IS LESS THAN BUSINESS KILOMTERS - Change Closing Kilometers" TAX_Year_date.Show 'values are correctly entered proceed to next step Range("b9").Value = TextBox2 End If Unload Me End Sub
Some times the values work sometimes it doesnt - Not sure why not. See attached pictures
Working Forum.png
Not Working Forum MSGBox.png
Not Working Forum MSGBox 2.png
Bookmarks