Find a number and return corresponding fields in that record

J

JBad

Hi..
i want to find a number (employee code) and if that exists in the table
(employee master), then retrieve the rest of the details of that record and
display those deails in either textboxes or labels (which would b not
editable).

wht is the easiest way to do it? i've tried the findrec & bookmark methods
but i cant make it work..
following is the code i use for bookmark method:

Dim rs As Recordset

Set rs = Me.RecordsetClone

rs.FindFirst “EmpNo = “ & txtBox_1.Value 'txtBox_1.value is wht the
user enters

If Not rs.NoMatch = True Then
Me.Bookmark = rs.Bookmark

End If
 
E

Evi

Create a form based on Employee Master and containing those fields which you
want to see. In Design View, click on Properties and on the Data tab you can
set Allow Editions, Allow Deletes etc to No.

When you add your button, choose the option to open this form and to display
certain records, choose any field for your match. It won't give you the
option of your text box but that doesn't matter.

Edit the code so that instead of saying eg
stLinkCriteria = "[CmID]=" & Me![CmID]

it now says your true criteria

stLinkCriteria = "[EmpCode]=" & Me.txtBox_1

(if EmpCode is a number field)

or

stLinkCriteria = "[EmpCode]=" & "'" & Me.txtBox_1 & "'"

(if it is text)


The bit after the ampersand and at the end is

Quote Apostrophe Quote

Evi
 

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