Close Data
Clear 
mDatabase=Space(30)
@ 10,10 Say 'Input Long Database ' Get mDatabase
Read
dDatabase=Ltrim(Rtrim(mDataBase))+'.Dbf'
cDatabase=Ltrim(Rtrim(mDatabase))+'.Cdx'
** Check Location
fDatabase = dDatabase
fcDatabase= cDatabase
If .not. File(fDatabase) 
   fDatabase='Data\'+dDatabase
   fcDatabase='Data\'+cDatabase
Endif 
If .not. File(fDatabase) 
   fDatabase='Transac\'+dDatabase
   fcDatabase='Transac\'+cDatabase
Endif 
If .not. File(fDatabase) 
   fDatabase='Data\Transac\'+dDatabase
   fcDatabase='Data\Transac\'+cDatabase
Endif 
If .not. File(fDatabase) 
   fDatabase='Data\001\'+dDatabase
   fcDatabase='Data\001\'+cDatabase
Endif 
If .not. File(fDatabase) 
   fDatabase='Data\002\'+dDatabase
   fcDatabase='Data\002\'+cDatabase
Endif 
If .not. File(fDatabase) 
   fDatabase='Data\003\'+dDatabase
   fcDatabase='Data\003\'+cDatabase
Endif 
If .not. File(fDatabase) 
   fDatabase='Data\004\'+dDatabase
   fcDatabase='Data\004\'+cDatabase
Endif 
**
dDatabase=fDatabase
cDatabase=fcDatabase
If File(dDataBase) 
    i = 1
    Do While .T.
        bDatabase = 'BakDbase\D'+Rtrim(Ltrim(Str(I)))
        If .not. File(bDataBase+'.Dbf')
            Exit
        Endif 
        i = i+1
    Enddo
    Use &dDataBase
    Copy To TmData
    Copy To &bDataBase
    Use Tmdata
    Copy To &dDataBase
    Close Data
    If File(cDataBase)
        Delete File &cDataBase
    Endif 
    Quit
Else
    Clear
    If Len(Trim(mDatabase))<>0
        @ 10,10 Say 'Not Found Database Please Input Again'
        Wait 
    Endif 
Endif 
Close Data
