How do I select records using a combo box (rather than the navigat

C

cuyeda

I have a simple table that stores addresses of people. It looks like this:

ID Name Phone Number
1 Suzy 978-4658
2 Tom 876-1234

I want to use a form that allows a user to update the addresses of people.

When I create a form using the wizard, I move between records using the
navigator buttons. But I want to move between records using a combo box that
lists all the names in the table.

Why? Because if I had 100 names in the table I don't want the user to click
through the navigator to find their record. I want them to use a combo box
that allows them to quickly locate the name and then update the address for
that record.

How do I do this? Thanks.
 
K

Klatuu

Use the After Update event of the combo box to navigate to the selected record.
For example purposes, I will assume ID is the primary key.

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

Change MyCombo to the name of you combo box.
 
C

cuyeda

Thanks a million. You are an MVP indeed.

(And I also just discovered that the wizard gives you an option to
automatically do this when you create the combo box - but I'm glad I know the
code to do it myself now).

Klatuu said:
Use the After Update event of the combo box to navigate to the selected record.
For example purposes, I will assume ID is the primary key.

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

Change MyCombo to the name of you combo box.
--
Dave Hargis, Microsoft Access MVP


cuyeda said:
I have a simple table that stores addresses of people. It looks like this:

ID Name Phone Number
1 Suzy 978-4658
2 Tom 876-1234

I want to use a form that allows a user to update the addresses of people.

When I create a form using the wizard, I move between records using the
navigator buttons. But I want to move between records using a combo box that
lists all the names in the table.

Why? Because if I had 100 names in the table I don't want the user to click
through the navigator to find their record. I want them to use a combo box
that allows them to quickly locate the name and then update the address for
that record.

How do I do this? Thanks.
 
K

Klatuu

The more experience you get, the less you will use wizards.
Glad I could help.
--
Dave Hargis, Microsoft Access MVP


cuyeda said:
Thanks a million. You are an MVP indeed.

(And I also just discovered that the wizard gives you an option to
automatically do this when you create the combo box - but I'm glad I know the
code to do it myself now).

Klatuu said:
Use the After Update event of the combo box to navigate to the selected record.
For example purposes, I will assume ID is the primary key.

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

Change MyCombo to the name of you combo box.
--
Dave Hargis, Microsoft Access MVP


cuyeda said:
I have a simple table that stores addresses of people. It looks like this:

ID Name Phone Number
1 Suzy 978-4658
2 Tom 876-1234

I want to use a form that allows a user to update the addresses of people.

When I create a form using the wizard, I move between records using the
navigator buttons. But I want to move between records using a combo box that
lists all the names in the table.

Why? Because if I had 100 names in the table I don't want the user to click
through the navigator to find their record. I want them to use a combo box
that allows them to quickly locate the name and then update the address for
that record.

How do I do this? Thanks.
 
Top