Access record with ID

L

Ladypep13

I have a member's database where each record has an auto-assigned ID number.
(ID is the primary key). I have created a form for entry into the main
table. What I need now is a form that is edit only. I need to be able to
pull up the edit form and put in the member ID and have it pull up that
member. I'm a little lame with Access, so I haven't been able to figure out
how to do that since it is an auto-assigned field. Does anybody know how I
can do this?
 
G

Golfinray

Put a combo box on your form. Have the wizard do it for you and have it
assign member ID as its source. Now right click on the combo in design view
and click on the events tab. On the AfterUpdate event, click the little
button out to the right and select code builder. Type
me.filter = "[member ID] = """ & me.combo# & """"
me.filteron = true
The combo number will be listed, like combo4 or combo22
 
K

Klatuu

me.filter = "[member ID] = """ & me.combo# & """"
Not with an autonumber field. Your syntax is for a text field
Also, filtering the form would not be the way to go on this.

My suggestio would be an unbound combo box to use for searching. I would
suggest that an automatically assigned number might not be the best way to
find an entry. Peoples names are much easier to remember and recognize than
an arbitrary number (at least for us humans).

The usual technique is to create a two column combo that presents the name
so the human can find the entry easily and the autonumber primary key so the
computer can find it easily.

The combo's row source would be something like:

SELECT MemberID, MemberLastName & ", " & Member FirstName From tblMembers
ORDER BY MemberLastName, MemberFirstName;

Then set the following combo properties:
Bound Column 1
Column Count 2
Column Widths 0"; 3" (The 0" hides the ID, the 3" can be however wide
necessary to show the name.

Now, use the combo's After Update event to make the member's record the
current record:

Private Sub cboMemberSearch_AfterUpdate()

With Me.RecordsetClone
.FindFirst "[MemberID] = " & Me.cboMemberSearch
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With

End Sub
--
Dave Hargis, Microsoft Access MVP


Golfinray said:
Put a combo box on your form. Have the wizard do it for you and have it
assign member ID as its source. Now right click on the combo in design view
and click on the events tab. On the AfterUpdate event, click the little
button out to the right and select code builder. Type
me.filter = "[member ID] = """ & me.combo# & """"
me.filteron = true
The combo number will be listed, like combo4 or combo22

Ladypep13 said:
I have a member's database where each record has an auto-assigned ID number.
(ID is the primary key). I have created a form for entry into the main
table. What I need now is a form that is edit only. I need to be able to
pull up the edit form and put in the member ID and have it pull up that
member. I'm a little lame with Access, so I haven't been able to figure out
how to do that since it is an auto-assigned field. Does anybody know how I
can do 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

Top