Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paradox tables and keys

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
This is the first time that I have used the Paradox tables and am having a little bit of trouble.

A little background about this form and query: when a person is summoned for jury duty, one of the valid reasons for excusal is prior jury service within the last three years. So, I have a form with a DBGrid that lists all the peopled summoned over the last 3 years so the user can check if the person really did serve.

So, I have a query that returns about 33,000 rows, a TBatchMove component that moves all the records to my Paradox DB, a datasource with the table as the source and a DBGrid with the datasource as the source.

Since this is a date sensitive excusal, a person could conceivably be not eligible today, but would be eligible tomorrow. So, in the Form Activate event I am emptying the table and re-filling it if it hasn't already been done for the session. Unfortunately when I empty the table, my Key is gone and the FindNearest doesn't work anymore! I get the error:

'No index is currently active'

Can someone please tell me how to activate the index???

Thanks!



Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Why do you want to do a FindNearest when the table is empty?

How are you emptying the table?

Andrew
 
The table isn't empty. It has 33000 records of people previously summoned for jury duty.

Code:
procedure TfrmPriorServ.FormActivate(Sender: TObject);
begin
  If not frmPriorServ.NewTable then
  begin
    with JMSData.qrySearch do
    begin
      DisableControls;
      Active:= False;
      Unprepare;
      JMSData.qrySearch.ParamByName('CUTOFF1').AsString := FormatDateTime('YYYYMMDD',IncYear(Today,-4));
      JMSData.qrySearch.ParamByName('CUTOFF2').AsInteger := StrToInt(FormatDateTime('YYYYMMDD',IncYear(Today,-4)));
      Prepare;
      Active:= True;
      First;
      JMSData.TBPriorServ.Close;
      JMSdata.TBPriorServ.EmptyTable;
      JMSData.TBPriorServ.Open;
      while not EOF do
      begin
        JMSData.TBPriorServ.Append;
        JMSData.TBPriorServ.FieldByName('JURNUM').AsInteger:=
          FieldByName('JURNUM').AsInteger;
        JMSData.TBPriorServ.FieldByName('LASTNAME').AsString:=
          FieldByName('LASTNAME').AsString;
        JMSData.TBPriorServ.FieldByName('FIRSTNAME').AsString:=
          FieldByName('FIRSTNAME').AsString;
        JMSData.TBPriorServ.FieldByName('SSN').AsString:=
          FieldByName('SSN').AsString;
        JMSData.TBPriorServ.FieldByName('STATUSCD').AsString:=
          FieldByName('STATUSCD').AsString;
       JMSData.TBPriorServ.FieldByName('TYPE').AsString:=
          FieldByName('TYPE').AsString;
       JMSData.TBPriorServ.Post;
        Next;
      end;
      EnableControls;
      Close;
      frmPriorServ.NewTable := True;
    end;
  end;
end;

procedure TfrmPriorServ.edLastNmCritChange(Sender: TObject);
begin
  JMSData.TBPriorServ.FindNearest([UpperCase(edLastNmCrit.Text)]);
end;

Let me also say, this worked like I wanted at one point (the user enters a name in an edit box and it moved there in the DBGrid) and I don't know what happened to make it not work! Now I keep getting 'No Index Currently Active' error when entering something in edLastNameCrit. I also tried a Batch Move component, but when I started having problems with the index I went back to the Append each item (as shown above).
I'm so confused!!!

Thanks!
Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
I finally got this to work! I had to define a key in the Database Desktop and then I could create a secondary index on the last names to search!

Leslie
landrews@metrocourt.state.nm.us

SELECT * FROM USERS WHERE CLUE > 0
No Rows Returned
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top