I tried to code immediate changes to the index everytime a name changed, but
I'm not knowledgable enough to do that. I thought if I had a macro or a
module that would rebuild it whenever I wanted, that would solve the problem.
What I plan to do is:
Copy tblIndex to tblIndexbkp 'to create a backup copy in case of trouble.
You're far more likely to have corruption on your entire .mdb database than to
have corruption on a single table. I'd suggest backing up your .mdb file
before you even OPEN it to do this operation.
Delete all records from tblIndex 'why I need a backup
Open tblAlumnus as readonly
Open tblIndex as edit
Read tblAlumnus
Do until EOD
Write LastName, FirstName, MiddleName, AlumnusID to tblIndex
If PrevSurName is blank then
Else
Write PrevSurName, FirstName, MiddleName, AlumnusID to tblIndex
If Nickname is blank then
Else
Write PrevSurName, Nickname, MiddleName, AlumnusID to tblIndex
EndIF
EndIF
If Nickname is blank then
Else
Write LastName, Nickname, Middlename, AlumnusID to tblIndex
EndIF
Read tblAlumnus
EndDo
EndRoutine
There is probably an easier way. Would you tell me what it is?
Two suggestions:
Run one very simple Append query:
INSERT INTO tblIndex(LastName, FirstName, MiddleName, AlumnusID)
SELECT NZ(PrevSurName, LastName), NZ(Nickname, Firstname), Middlename,
AlumnusID) FROM tblAlumnus;
and don't use any recordset or code at all; or, even better, create a Select
query
SELECT NZ(PrevSurName, LastName) AS OldLastName, NZ(Nickname, Firstname) AS
OldNickname, Middlename, AlumnusID) FROM tblAlumnus;
and name it qryIndex, and don't bother deleting tblIndex or recreating it AT
ALL.
You can do anything with qryIndex that you would do with tblIndex: base a
Report on it, base a Form on it, export it, etc. The only thing you wouldn't
be able to do is edit the OldLastName or OldNickname fields.
John W. Vinson [MVP]