VBA Help

R

Runner77

Hi,

I have set up a multitab form I have set up the following code to allow
me to update my database, but when I Click in the button to update it
updates the database, but does not take me back to the first tab so I
can start over. See code Below.

Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdCancel2_Click()
Unload Me
End Sub
Private Sub cmdNewEmp_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Payroll Data")
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

ws.Cells(iRow, 1).Value = Me.txtEmpID.Value
ws.Cells(iRow, 2).Value = Me.txtFirstName.Value
ws.Cells(iRow, 3).Value = Me.txtLastName.Value
ws.Cells(iRow, 4).Value = Me.txtAddress.Value
ws.Cells(iRow, 5).Value = Me.txtSuburb.Value
ws.Cells(iRow, 6).Value = Me.txtPostCode.Value
ws.Cells(iRow, 7).Value = Me.cbGender.Value
ws.Cells(iRow, 8).Value = Me.txtDOB.Value
ws.Cells(iRow, 9).Value = Me.txttax.Value
ws.Cells(iRow, 10).Value = Me.txtStart.Value
ws.Cells(iRow, 11).Value = Me.cbEmpLevel.Value
ws.Cells(iRow, 12).Value = Me.cbDivision.Value
ws.Cells(iRow, 13).Value = Me.cbEmpStatus.Value
ws.Cells(iRow, 14).Value = Me.txtRemun.Value
ws.Cells(iRow, 15).Value = (Me.txtRemun / 109) * 100

Me.txtEmpID.Value = ""
Me.txtFirstName.Value = ""
Me.txtLastName.Value = ""
Me.txtAddress.Value = ""
Me.txtSuburb.Value = ""
Me.txtPostCode.Value = ""
Me.cbGender.Value = ""
Me.txtDOB.Value = ""
Me.txttax.Value = ""
Me.txtStart.Value = ""
Me.cbEmpLevel.Value = ""
Me.cbDivision.Value = ""
Me.cbEmpStatus.Value = ""
Me.txtRemun.Value = ""

End Sub



Private Sub UserForm_Initialize()
cbGender.AddItem "Female"
cbGender.AddItem "Male"
cbEmpLevel.AddItem 1
cbEmpLevel.AddItem 2
cbEmpLevel.AddItem 3
cbEmpLevel.AddItem 4
cbDivision.AddItem "Legal"
cbDivision.AddItem "Management"
cbDivision.AddItem "Service"
cbDivision.AddItem "Training"
cbDivision.AddItem "Accounting"
cbDivision.AddItem "Cleaners"
cbDivision.AddItem "Admin"
cbDivision.AddItem "Other"
cbDivision.AddItem "Adminstration"
cbDivision.AddItem "Secretary"
cbDivision.AddItem "Account Managers"
cbEmpStatus.AddItem "Full-Time"
cbEmpStatus.AddItem "Part-Time"
End Sub
 
B

Bob Phillips

Do you just want the code to select the first page of the multitab?

MultiPage1.Value = 0

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top