create variable to return corresponding record number

  • Thread starter Thread starter Damian
  • Start date Start date
D

Damian

Hi, I'm trying to create a variable that will return a record number that
corresponds to a particular value in one of my fields (Access 2003).
Example... In my database I have a field called "Site_ID" containing unique
numerical values. How do I find out the record number for say Site_ID = 27?
Cheers, Damian
 
Hi, I'm trying to create a variable that will return a record number that
corresponds to a particular value in one of my fields (Access 2003).
Example... In my database I have a field called "Site_ID" containing unique
numerical values. How do I find out the record number for say Site_ID = 27?
Cheers, Damian

Since Access tables do not HAVE record numbers, *you can't*.

A Table is not like a spreadsheet. It does not have a fixed, immutable order;
it should be viewed as an unordered heap of records. Compacting the database
may reorder the records, for example.

Why? What use do you feel that you need to make of the "record number"? I
suspect there are other ways to accomplish your end!
 
Hi John, thanks for your response. Sorry, "record number" is possibly a bad
term - better just to say "record"

To expand on my problem, I have a form and a subform. The subform is for
"Site" information (Site_Id, site_name, latitude, longitude, elevation, etc).
In this subform, the user can click a button to open up another form to
display a list of sites (in datasheet view) that have already been entered.
If the user wishes to use one of these existing sites, he/she can select a
record, I have an event procedure set up so that the "Site_ID" (my primary
key) of the selected record is written back to my subform. Every works fine
to this point.

My problem is, I can't get my subform to automatically goto this record on
my subform and display all the corresponding site information after the
record is selected and written to my sub form - I can only manually navigate
to it at this stage. I thought I could use the "GoToRecord" method - e.g.

DoCmd.GoToRecord acActiveDataObject, , acGoTo, varRecordNumber

where "varRecordNumber" corresponds to the record (number) of the value of
my "Site_ID" field. This is why I was trying to create a variable to return a
record (number). Is this not possible? Is there a better way?

Cheers, Damian
 
Back
Top