switch(Key)
{
case VK_PRIOR:
ClientForm->ChiefQuery->First();
if(ClientForm->songbook2&&Label1->Caption!=ClientForm->ChiefQuery->FieldByName("SongName")->AsString)
{
ClientForm->ChiefQuery->GotoBook(ClientForm->songbook2);
for(int i=1;i<=5;i++)
{
ClientForm->ChiefQuery->Prior();
if(i==1)
ClientForm->songbook1=ClientForm->ChiefQuery->GetBook();
switch(i)
{
case 5:
SongIndexForm->Label1->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label6->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 4:
SongIndexForm->Label2->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label7->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 3:
SongIndexForm->Label3->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label8->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 2:
SongIndexForm->Label4->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label9->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 1:
SongIndexForm->Label5->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label10->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
}
if(i==5)
ClientForm->songbook2=ClientForm->ChiefQuery->GetBook();
}
}
break;
case VK_NEXT:
{
if(!ClientForm->ChiefQuery->Eof){
ClientForm->ChiefQuery->GotoBook(ClientForm->songbook1);
for(int i=1;i<=5;i++)
{
//if(!ClientForm->ChiefQuery->Eof){
ClientForm->ChiefQuery->Next();
if(i==1)
ClientForm->songbook2=ClientForm->ChiefQuery->GetBook(); switch(i)
{
case 1:
SongIndexForm->Label1->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label6->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 2:
SongIndexForm->Label2->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label7->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 3:
SongIndexForm->Label3->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label8->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 4:
SongIndexForm->Label4->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label9->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 5:
SongIndexForm->Label5->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label10->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
}
if(i==5)
ClientForm->songbook1=ClientForm->ChiefQuery->GetBook();
} }
}
break;
{
case VK_PRIOR:
ClientForm->ChiefQuery->First();
if(ClientForm->songbook2&&Label1->Caption!=ClientForm->ChiefQuery->FieldByName("SongName")->AsString)
{
ClientForm->ChiefQuery->GotoBook(ClientForm->songbook2);
for(int i=1;i<=5;i++)
{
ClientForm->ChiefQuery->Prior();
if(i==1)
ClientForm->songbook1=ClientForm->ChiefQuery->GetBook();
switch(i)
{
case 5:
SongIndexForm->Label1->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label6->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 4:
SongIndexForm->Label2->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label7->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 3:
SongIndexForm->Label3->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label8->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 2:
SongIndexForm->Label4->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label9->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 1:
SongIndexForm->Label5->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label10->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
}
if(i==5)
ClientForm->songbook2=ClientForm->ChiefQuery->GetBook();
}
}
break;
case VK_NEXT:
{
if(!ClientForm->ChiefQuery->Eof){
ClientForm->ChiefQuery->GotoBook(ClientForm->songbook1);
for(int i=1;i<=5;i++)
{
//if(!ClientForm->ChiefQuery->Eof){
ClientForm->ChiefQuery->Next();
if(i==1)
ClientForm->songbook2=ClientForm->ChiefQuery->GetBook(); switch(i)
{
case 1:
SongIndexForm->Label1->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label6->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 2:
SongIndexForm->Label2->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label7->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 3:
SongIndexForm->Label3->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label8->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 4:
SongIndexForm->Label4->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label9->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
case 5:
SongIndexForm->Label5->Caption=ClientForm->ChiefQuery->FieldByName("SongName")->AsString;
SongIndexForm->Label10->Caption=ClientForm->ChiefQuery->FieldByName("SongerName")->AsString;
break;
}
if(i==5)
ClientForm->songbook1=ClientForm->ChiefQuery->GetBook();
} }
}
break;
case VK_NEXT:
{
if(!ClientForm->ChiefQuery->Eof){
ClientForm->ChiefQuery->GotoBook(ClientForm->songbook1);
for(int i=1;i<=5;i++)
{
//if(!ClientForm->ChiefQuery->Eof){
ClientForm->ChiefQuery->Next();
这里被你注释掉的一个if判断应该要回来。当按下next键之后,应该判断当前是否到了表的最后,如果是就马上退出,否则才继续判断I值去取数据。