Hello Access-Programmers,
I have a table (tblContact) with an auto number key field that is numbered sequentially (1-8) there are no deletions, each new record is appended.
I wrote a simple FindFirst line to locate a record that is the first record in the table. The FindFirst failed to find the record.
So, I wrote a Do Until Loop that cycles through each record looking for the record that I want to find (the first record with key field 1).
This works to find the first record... eventually, because it does not begin its search at the first record. The results in the immediate window are below.
I believe the field CEmployerID is unrelated to the issue. I am also attaching screen shots of the table "tblContact" and code with immediate window. I have tried indexing and not indexing the CEmployerID field in the Contact table to no avail. Even though the Do Until Loop eventually finds my record, it bothers me that the more simple Findfirst command is ineffective and I would like to know why and how to fix this. Any ideas where I have gone amiss?
I have a table (tblContact) with an auto number key field that is numbered sequentially (1-8) there are no deletions, each new record is appended.
I wrote a simple FindFirst line to locate a record that is the first record in the table. The FindFirst failed to find the record.
So, I wrote a Do Until Loop that cycles through each record looking for the record that I want to find (the first record with key field 1).
Code:
rstContact.MoveFirst
Debug.Print "ContactID: " & rstContact.Fields("ContactID")
Debug.Print "CEmployerID: " & rstContact.Fields("CEmployerID") & vbCrLf
Do Until rstContact.EOF
Debug.Print "ContactID: " & rstContact.Fields("ContactID")
Debug.Print "CEmployerID: " & rstContact.Fields("CEmployerID") & vbCrLf
This works to find the first record... eventually, because it does not begin its search at the first record. The results in the immediate window are below.
Code:
ContactID: 4
CEmployerID: 2
ContactID: 4
CEmployerID: 2
ContactID: 5
CEmployerID: 4
ContactID: 6
CEmployerID: 3
ContactID: 7
CEmployerID: 1
ContactID: 8
CEmployerID: 5
ContactID: 1
CEmployerID: 1
I believe the field CEmployerID is unrelated to the issue. I am also attaching screen shots of the table "tblContact" and code with immediate window. I have tried indexing and not indexing the CEmployerID field in the Contact table to no avail. Even though the Do Until Loop eventually finds my record, it bothers me that the more simple Findfirst command is ineffective and I would like to know why and how to fix this. Any ideas where I have gone amiss?
Attachments
Last edited: