• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Userform fields to database question?

I am down to the last piece of my excel document that I am creating. I have a userform which is to be used by up to 3 people to provide electronic signatures. The intention is that one button on the excel document will open one userform but each of 3 different people will need to use it to approve the document at 3 different times. When the employee enters the userform, they enter their name and date and then check the checkbox that says 'I approve'. These pieces of information are then moved to the employee fields on the excel document. The employee sends the document to their supervisor and the supervisor reviews and does the same in the 'supervisor' fields. They enter their name and date and check the 'I approve' checkbox in the supervisor section. This moves the supervisor name, the date and the supervisor's computer name and username to the excel document. And on to the higher supervisor if needed (the supervisor will know if it is needed to go higher than themselves). I am attaching a screenshot of the userform for reference as well as the excel document fields where these pieces of info should go.

What I am experiencing is that I can test and enter all 3 approval information into the userform and it will transfer all info to the excel document. However, if I enter only the employee, the employee info is going to the excel document but if I go back in and enter the info as the supervisor, only the computer name and computer username is going to my excel document, and the same is happening with the 3rd approval as well. Could someone please tell me what I need to do differently to make this work appropriately? My code is below:



Code:
Private Sub SignatureForm()
frmSignature.Show

End Sub
Public Sub chkEmployee_click()

Dim ComputerName, UserName As String

'Getting computer name
ComputerName = Environ("computername")

'Getting user name
UserName = Environ("username")

'''BEGIN DATA MOVE INTO DATABASE'''
Sheets("Travel Expense Voucher").Range("EEDate").Value = txtEEDate
Sheets("Travel Expense Voucher").Range("EEName").Value = txtEEName
Sheets("Travel Expense Voucher").Range("EECompName").Value = ComputerName
Sheets("Travel Expense Voucher").Range("EECompUName").Value = UserName

End Sub

Public Sub chkSupervsr_click()

Dim ComputerName, UserName As String

'Getting computer name
ComputerName = Environ("computername")

'Getting user name
UserName = Environ("username")

'''BEGIN DATA MOVE INTO DATABASE'''
Sheets("Travel Expense Voucher").Range("ORDate").Value = txtEEDate
Sheets("Travel Expense Voucher").Range("ORName").Value = txtEEName
Sheets("Travel Expense Voucher").Range("ORCompName").Value = ComputerName
Sheets("Travel Expense Voucher").Range("ORCompUName").Value = UserName

End Sub

Public Sub chkDO_click()

Dim ComputerName, UserName As String

'Getting computer name
ComputerName = Environ("computername")

'Getting user name
UserName = Environ("username")

'''BEGIN DATA MOVE INTO DATABASE'''
Sheets("Travel Expense Voucher").Range("DODate").Value = txtEEDate
Sheets("Travel Expense Voucher").Range("DOName").Value = txtEEName
Sheets("Travel Expense Voucher").Range("DOCompName").Value = ComputerName
Sheets("Travel Expense Voucher").Range("DOCompUName").Value = UserName

End Sub

Public Sub cmdSigsSubmit_Click()
'When submit button is clicked

Unload frmSignature

End Sub
 

Attachments

Logit

Active Member
It appears you are using the same TEXTBOXES in your code for the employee, the supervisor and the final approval.
txtEEDate and txtEEName

You will need to give the text boxes for the supervisor a different name from the employee text boxes.

Then, give the text boxes for the final approval a different name from all the rest.
 
You were on the right track, however, what triggered in my brain was the actual naming of the fields on the userform. They were not named the same as the names I gave in my coding. So very sorry, but thank you for the brain trigger. :) Total rookie mistake on my part!
 
Top