userform question

viper

Active Member
Joined
Feb 15, 2002
Messages
382
I am using a userform to input accounts and amounts into a ledger. How can I make sure that individual account amounts match the invoice total and if not let the user know so that the user can check the input before the userform posts to the ledger?

I've tried inserting a separate module and used this code:

Sub CheckData()
If Textbox1.Value = Textbox2.Value + Textbox3.Value + Textbox3.Value + Textbox4.Value Then

Exit Sub

Else MsgBox ("Please check your input, account s and invoice don't match!")

End IF

End Sub

I called this module before the posting of the information but it didn't work. It posted it anyway not matter if the totals matched or not.

Thanks,
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
I think that having the function check your invoice amounts and then returning a value would be better. Something like this:

Code:
Function CheckData() as Boolean

CheckData = (Textbox1.Value = Textbox2.Value + Textbox3.Value + Textbox3.Value + Textbox4.Value) 

End Function
Exit Sub

In the procedure where you will be sending the data to the sheet, put something like this:

If Not CheckData Then
MsgBox ("Please check your input, account s and invoice don't match!")
Exit Sub
End If

________________

Hope this helps,

Russell

p.s. - I just noticed that you are adding TextBox3 twice in your example...which I copied for my example.
This message was edited by Russell Hauf on 2002-03-28 12:59
 
Upvote 0

Forum statistics

Threads
1,214,812
Messages
6,121,699
Members
449,048
Latest member
81jamesacct

We've detected that you are using an adblocker.

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.
Go back
Back
Top