MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

If not found then data entry

  Asked By: Josefina    Date: Sep 20    Category: MS Office    Views: 1019

I have a routine that looks for badge numbers out of different files.
If a badge number isn't listed in the file I want the end user to be
able to type the number, employees name and department. How would I do
this? The code is listed below:

Private Sub intBadge_AfterUpdate()

If IsNumeric(intBadge) Then

txtEEName.Text = Application.VLookup(Val(intBadge), _

2, 0)

txtDept.Text = Application.VLookup(Val(intBadge), _

Workbooks("Supplies.CSV").Worksheets("Supplies").Range("A:D"), 3, 0)

txtSSN.Text = Application.VLookup(Val(intBadge), _

Workbooks("Supplies.CSV").Worksheets("Supplies").Range("A:D"), 4, 0)

intQTY1 = "1"



txtEEName.Text = Application.VLookup(intBadge, _

Employees.xls").Worksheets(1).Range("A:C"), 2, 0)

txtDept.Text = Application.VLookup(intBadge, _

Employees.xls").Worksheets(1).Range("A:D"), 3, 0)

intQTY1 = "1"


End If


MsgBox "ID Check! If correct, type Employee's Name",
vbOKOnly, "ID Error"

End Sub



1 Answer Found

Answer #1    Answered By: Chaths Massri     Answered On: Sep 20

You will need to make a userForm with the three textboxes on it. (and a label
telling the user  what to do). Also include two buttons one for OK and one for

Declare (Dim) the three variables outside the sub so they are available to
both the sub and the form

In the sub put Userform1.show

In the form code  for the OK button put code to set each of the three variables
equal to the textboxes on the form
Then put

Unload me

Also put unload me in the sub for the cancel button (you might need to put
some more code to handle errors, cancellation etc)

Didn't find what you were looking for? Find more on If not found then data entry Or get search suggestion and latest updates.