PDA

View Full Version : Need UserForm for Data Input



TonC
12-09-2016, 04:06 AM
Hello,

I’ve got a form (popup form), and within that form, there are three fields, named,
amount
mutation
and remnant.

What I want to do is when I put a amount in the field amount, and I put a amount in the field mutation,
The must come a balance in the field remnant.

My question is when I click a button, I want to tranfer the mutation amount to another tabel, and the field amount
has to be adjusted tot he new amount

For example:
-40 Field amount
-10 Field mutation
-30 Field remnant

So, when I click a button, the amount of -10 must go to another table, but the field amount must change in -30.

I hope you understand my question, I’am sorry for my english. If you need more info, I will sure give it to you.

greetings,

SamT
12-09-2016, 06:07 AM
Copy the code in the Form.

In our VBA Express Post Editor, click the # icon on the menu.

Press Ctrl+V to paste the copied code between the New [ CODE] [/CODE ] tags in the post.

TonC
12-09-2016, 09:20 AM
Hello, I don't know what the code is for this question. Or even is it possible to do so.

SamT
12-09-2016, 09:55 AM
I changed the Thread Title to better say what you need.

Logit
12-09-2016, 06:03 PM
This small project does what you are seeking. There are other changes that you will need to make I am certain. Best wishes !

Code in the UserForm:


Option Explicit

Sub CommandButton1_Click()

'send answer to sheet1
Sheets("Sheet1").Range("B5") = Val(TextBox3.Text)


'move mutation val to textbox1 then clear textboxes
TextBox1.Text = Val(TextBox3.Text)
TextBox2.Text = ""
TextBox3.Text = ""

End Sub


Private Sub CommandButton2_Click()
'clear all fields if calculation error made
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub


Private Sub TextBox2_Change()
'do the math
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub