how to show emaployee information

J

Jon

Greeting,

I have a form for showing employees info. In this form I have a text box for
employee ID. The other text boxes are employee first name, Mid Name , age,
and address. What I want to do is when I input employee ID in the text box ,
all above info appear . how to do that??
 
W

Wayne-I-M

Hi Jon

Create an unbound text box (not bound to a table field) on your form.
Call it txtSearch

In the afterUpdate event row (properties box - event column) put this code

Private Sub txtSearch_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[employee ID] = " & Str(Nz(Me![txtSearch], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.firstname.SetFocus
Me.txtSearch = ""
End Sub

I have assumed you have a control called employeeID (no space between
employee and ID) and another called first firstname (with no space between
first and name). If not change the code to what they are really called

Good Luck
 
W

Wayne-I-M

ooops - should be

Private Sub txtSearch_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[employeeID] = " & Str(Nz(Me![txtSearch], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.firstname.SetFocus
Me.txtSearch = ""
End Sub



--
Wayne
Manchester, England.



Wayne-I-M said:
Hi Jon

Create an unbound text box (not bound to a table field) on your form.
Call it txtSearch

In the afterUpdate event row (properties box - event column) put this code

Private Sub txtSearch_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[employee ID] = " & Str(Nz(Me![txtSearch], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.firstname.SetFocus
Me.txtSearch = ""
End Sub

I have assumed you have a control called employeeID (no space between
employee and ID) and another called first firstname (with no space between
first and name). If not change the code to what they are really called

Good Luck

--
Wayne
Manchester, England.



Jon said:
Greeting,

I have a form for showing employees info. In this form I have a text box for
employee ID. The other text boxes are employee first name, Mid Name , age,
and address. What I want to do is when I input employee ID in the text box ,
all above info appear . how to do that??
 
L

Larry Linson

Jon said:
Greeting,

I have a form for showing employees info. In this form I have a text box
for
employee ID. The other text boxes are employee first name, Mid Name , age,
and address. What I want to do is when I input employee ID in the text box
,
all above info appear . how to do that??

Wayne I-M gave you accurate information, but it very likely will be easier
if you add a Combo Box to your Form, and choose the option that allows you
to select information to be displayed. That will automate the process, and
eliminate the user having to type the exact name, as the Combo Box will
scroll as the user enters information.

Larry Linson
Microsoft Office Access MVP
 
W

Wayne-I-M

Jon

Larry is right. The problem with your method - which is fine for a very
small database where you always know the ID of someone - is that if you have
lots of people then how will you know the ID numbers.

There is a wizard you can use to create the combo Larry mentioned. Or
Better, you could create a query (sorted as you want it) with ID, 1stName,
Surname, Postcode,etc. Then base your combo on this.
 

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

Similar Threads


Top