Hello
I have written some coding to program a form I have developed. All works fine until the last piece of coding which should clear the form fields for use by the next user. This is the string of text
If MsgBox("Clear the Form?", vbYesNo + vbQuestion, "Employee Form") = vbYes Then frmEmployee.InitializeMe.Repaint
I keep getting an error message but I am not sure what I have written incorrectly in this line. The error reads "Method or Data Member not Found" I am not sure what this means. Can anyone provide some clarification or a correction to my string of text.
The Whole piece of coding reads:
Private Sub cmdAdd_Click()
'This Procedure copies the data from the form into the worksheet
'find the row after the end of the data
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
'enter employee number, first name, and last name
ActiveCell.Value = txtEmployeeNumber.Text
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = txtFirstName.Text
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = txtLastName.Text
'enter date of birth as a date and format it
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = DateValue(txtDOB.Text)
Selection.NumberFormat = "d-mmm-yy"
'enter the age
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "=(INT(TODAY()-" & _
ActiveCell.Offset(0, -1).Address_(RowAbsolute:=False, ColumnAbsolute:=False) & ")/365.25)"
Selection.NumberFormat = "#,##0"
'enter the region that is selected
ActiveCell.Offset(0, 1).Select
If optRegion1 Then ActiveCell.Value = "North"
If optRegion2 Then ActiveCell.Value = "South"
'enter the department that is displayed in the box
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = _
cboDepartment.List(cboDepartment.ListIndex)
'enter the Gross Pay
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Val(txtGrossPay.Text)
Selection.NumberFormat = "$#,##0"
'enter the Tax
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Val(txtTax.Text)
Selection.NumberFormat = "$#,##0"
'enter a formula for net pay
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "=" & ActiveCell.Offset(0, -2).Address(RowAbsolute:=False, ColumnAbsolute:=False) & "-" & ActiveCell.Offset(0, -1).Address(RowAbsolute:=False, ColumnAbsolute:=False)
'offer to clear the form when done
If MsgBox("Clear the Form?", vbYesNo + vbQuestion, "Employee Form") = vbYes Then frmEmployee.InitializeMe.Repaint
End If
End Sub
I have written some coding to program a form I have developed. All works fine until the last piece of coding which should clear the form fields for use by the next user. This is the string of text
If MsgBox("Clear the Form?", vbYesNo + vbQuestion, "Employee Form") = vbYes Then frmEmployee.InitializeMe.Repaint
I keep getting an error message but I am not sure what I have written incorrectly in this line. The error reads "Method or Data Member not Found" I am not sure what this means. Can anyone provide some clarification or a correction to my string of text.
The Whole piece of coding reads:
Private Sub cmdAdd_Click()
'This Procedure copies the data from the form into the worksheet
'find the row after the end of the data
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
'enter employee number, first name, and last name
ActiveCell.Value = txtEmployeeNumber.Text
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = txtFirstName.Text
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = txtLastName.Text
'enter date of birth as a date and format it
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = DateValue(txtDOB.Text)
Selection.NumberFormat = "d-mmm-yy"
'enter the age
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "=(INT(TODAY()-" & _
ActiveCell.Offset(0, -1).Address_(RowAbsolute:=False, ColumnAbsolute:=False) & ")/365.25)"
Selection.NumberFormat = "#,##0"
'enter the region that is selected
ActiveCell.Offset(0, 1).Select
If optRegion1 Then ActiveCell.Value = "North"
If optRegion2 Then ActiveCell.Value = "South"
'enter the department that is displayed in the box
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = _
cboDepartment.List(cboDepartment.ListIndex)
'enter the Gross Pay
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Val(txtGrossPay.Text)
Selection.NumberFormat = "$#,##0"
'enter the Tax
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = Val(txtTax.Text)
Selection.NumberFormat = "$#,##0"
'enter a formula for net pay
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "=" & ActiveCell.Offset(0, -2).Address(RowAbsolute:=False, ColumnAbsolute:=False) & "-" & ActiveCell.Offset(0, -1).Address(RowAbsolute:=False, ColumnAbsolute:=False)
'offer to clear the form when done
If MsgBox("Clear the Form?", vbYesNo + vbQuestion, "Employee Form") = vbYes Then frmEmployee.InitializeMe.Repaint
End If
End Sub