Go to a record based on a table field.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

I am trying to create a button that will take the user to the record they
specify in a text box. The will know what the primary key, but not the record
number. How can I retrieve the record number based on a tables primary key
field? or if there is another way please let me know.

regards,
Brian
 
It depends on what you mean by "record number". Do you mean the position in
the table? Typically, you would use the primary key to go to the desired
record. That or a where clause based on one or more fields.

Barry
 
Yes the position in the table. Basically the number that appears at the
bottom of the form. I know how to open a form based on a where
statement.(doCmd.OpenForm). I just can't seem to figure out how to move to a
record based on a where statement. If I use the OpenForm, then the user can't
continue to navigate through the records.

thanks,
Brian
 
BT said:
Yes the position in the table. Basically the number that appears at the
bottom of the form. I know how to open a form based on a where
statement.(doCmd.OpenForm). I just can't seem to figure out how to move to a
record based on a where statement. If I use the OpenForm, then the user can't
continue to navigate through the records.

What about DoCmd.FindRecord? It allows you to find a record based on criteria.

Barry
 
BT said:
Yes the position in the table. Basically the number that appears at the
bottom of the form. I know how to open a form based on a where
statement.(doCmd.OpenForm). I just can't seem to figure out how to move to a
record based on a where statement. If I use the OpenForm, then the user can't
continue to navigate through the records.

What about DoCmd.FindRecord? It allows you to find a record based on criteria.

Barry
 
Unfortunately the FindRecord method only searches the current field and won't
work for my intended purpose. If is there a property of a recordset that
returns the record number based on a SQL statement? Sort of like .RecordCount
returns the total.

If I had that, I could just use DoCmd.Goto.

Thanks again for responding
 
Recordsets expose an AbsolutePosition property. This might work woth
GoToRecord.

Barry
 
Thank you. That's what I needed to know. I finally got it to work by looping
through the record set until it reached the designated record, based on the
table's field. It took me awhile to figure out I needed to base the recordset
on a SQL statement with an Order By clause, rather then just the table.

regards,
Brian
 

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

Back
Top