How do I make a record containing "X" the current record? (1 Viewer)

Woof

Registered User.
Local time
Today, 21:51
Joined
Feb 13, 2012
Messages
12
Hi.

A form is bound to a table. Each field's data is displayed in various objects such as labels, text boxes etc. The table has a field called, for example, [ID]. It has hundreds of unique records but they are not sequential as it's been sorted by another field. I may want the record containing "XYZ123" to be the current record so that all the data from that record shows in the form.

What VBA commands should I be investigating please? I'm a newbie.

I have tried understanding GoToRecord however it seems to need the record number. How do I find out which record number contains "XYZ123" as it could be sorted many ways?

The following example uses the GoToRecord method to make the seventh record in the form Employees current:
DoCmd.GoToRecord acDataForm, "Employees", acGoTo, 7
Thanks.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:51
Joined
Aug 30, 2003
Messages
36,139
Have you tried the combo box wizard, choosing the third option, "Find a record..."?
 

Woof

Registered User.
Local time
Today, 21:51
Joined
Feb 13, 2012
Messages
12
Good morning PB and others.

Another weekend gone and another Monday morning. However I still do not have an answer to my problem. I'm using Access 2003 so I don't know if the wizard for other versions is different, but I can't see "the 3rd option, find a record".

I put a new combo box on my app. The wizard shows and the first choice is "combo box looks up the values" or "I will type in the values". It asks me for the source, then which fields from the source, then sort order, column width, label name and finish.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:51
Joined
Aug 30, 2003
Messages
36,139
The form needs to be bound to a table for the third option to appear. You can use the wizard on a sample form and then copy the code to your actual form. I'm on an iPad right now or I'd dig up the code. It uses a bookmark.
 

Woof

Registered User.
Local time
Today, 21:51
Joined
Feb 13, 2012
Messages
12
The form needs to be bound to a table for the third option to appear. You can use the wizard on a sample form and then copy the code to your actual form. I'm on an iPad right now or I'd dig up the code. It uses a bookmark.

I thought my form was bound. this is the code...

Code:
SELECT dbo_ExtendedIncidentDetails.* FROM dbo_ExtendedIncidentDetails ORDER BY dbo_ExtendedIncidentDetails.MI_Prinx;

But there is no third option showing. I am linked to the table though.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:51
Joined
Aug 30, 2003
Messages
36,139
I mean directly to a table. In the record source property would just be the table name. I don't know why, but the third option won't show up when you use SQL. I'll be at a computer in about an hour if you don't find the code.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:51
Joined
Aug 30, 2003
Messages
36,139
The code the wizard creates looks like:

Code:
  Dim rs As Object

  Set rs = Me.Recordset.Clone
  rs.FindFirst "[DriverID] = " & Me![cmbFindDriver]
  Me.Bookmark = rs.Bookmark
 

Users who are viewing this thread

Top Bottom