View Single Post
  #2  
Old May 24th, 2010, 04:41 PM posted to microsoft.public.access.forms
BruceM via AccessMonster.com
external usenet poster
 
Posts: 448
Default Having a difficult time with a lookup

Your question is about basic functionality, not bells and whistles. DLookup
is not the best way to go about this. Unless there is a specific reason you
want to search by number rather than name, I suggest using the combo box
wizard (use the "Find a record..." option) to set up a combo box that
includes the MemberID as a hidden (zero-width) column in the combo box Row
Source, which would also include LastName and FirstName. This should give
you basic search functionality.

It's more work, but more versatile, to make a query (I will call it qryFind)
that includes MemberID in the first column, and something like: FullName:
[LastName] & ", " & [FirstName] in the second column. Create a combo box
(cboFind), and set the following combo box properties:
Row Source: qryFind
Bound Column: 1
Column Count: 2
Column Widths: 0",1.5"

Click the event tab for the combo box Property Sheet. Click After Update,
click the three dots, and click Code Builder, OK if the code window does not
open directly. The cursor should be blinking between the Private Sub and End
Sub lines. Add the following code:

Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[MemberID] = " & Me.cboFind
Me.Bookmark = rs.Bookmark

This assumes MemberID is a number field. Use your own field and control
names where I have used placeholder names.

rp3886 wrote:
I am still new at trying to add the "bells and whistles" to Access.

I have a question concerning lookups. I have a database that has two tables:
BBBMembers and MemberTrainingLog. I also have a form named
MemberCPETrainingLog.

What I want to be able to do is this:

In the MemberCPETrainingLog form, I want to be able to input in the member ID
and have the corresponding member’s first name come up in the First Name
field of the same form. I also want the last name field in the form to be
filled in the same way. The function should look at the BBBMembers table for
the information.

Can this be done? I have tried looking at DLookups, but I am getting all
turned around. Thanks!


--
Message posted via http://www.accessmonster.com