alias does not exist

Post Reply
Ehab Samir Aziz
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

alias does not exist

Post by Ehab Samir Aziz »

I simulate fwbrow.prg and I faced the error alias does not exist though I have put use all over the module .

Code: Select all

static function editcust( oLbx, lAppend )
*-------------------------------------------
local oDlg
LOCAL oCbx
LOCAL oCbx2
LOCAL oCbx3
Local oGet
Local oGet2
Local oGet3
local h:=0
local V_CU_ACCT
local V_CU_NAME
local V_cu_stre
local V_cu_gove:=space(30)
local V_cu_city:=space(30)
local V_cu_coun:=space(30)
local v_co_cocmbo:=""
local v_ci_cocmbo:=""
local v_go_cocmbo:=""
local a_Fields[1]
local a_Vars[1]
local V_CU_phon
local V_CU_fax
local V_CU_MAN
local V_CU_mobi
local V_CU_appr
local lSave := .f.
local nOldRec := RecNo()
local bFilter := ""
local cFilter := ""
local aItems:={}

   DEFAULT lAppend := .f.

   if lAppend
      GOTO BOTTOM
      SKIP
   endif


select 1
*use cust
nOldRec := RecNo()
V_CU_ACCT:=cust->CU_ACCT
V_CU_NAME:=cust->CU_NAME
V_cu_coun:=cust->CU_coun
V_cu_city:=cust->CU_city
V_cu_gove:=cust->CU_gove
V_CU_stre:=cust->CU_stre
V_CU_phon:=cust->CU_phon
V_CU_fax:=cust->CU_fax
V_CU_MAN:=cust->CU_MAN
V_CU_mobi:=cust->CU_mobi
V_CU_appr:=cust->CU_appr

DEFINE DIALOG oDlg FROM 8, 2 TO 600, 700 PIXEL ;
TITLE If( lAppend, "New Customer", "Customer Update" )


   @ 1,2 SAY "&Account No." OF oDlg PIXEL 
   @ 1,50 SAY ":" OF oDlg PIXEL 
   @ 1,60 GET V_CU_ACCT OF oDlg PIXEL 

   @ 15,1 SAY "&Name" OF oDlg PIXEL
   @ 15,50 SAY ":" OF oDlg PIXEL
   @ 15,60 GET V_CU_NAME OF oDlg PIXEL

   @ 30,2 SAY "&Street" OF oDlg PIXEL
   @ 30,50 SAY ":" OF oDlg PIXEL
   @ 30,60 GET V_cu_stre OF oDlg PIXEL

  @ 45,2 SAY "&Country" OF oDlg PIXEL
  @ 45,50 SAY ":" OF oDlg PIXEL
  @ 45,60 GET oGet VAR V_cu_coun OF oDlg PIXEL
  @ 45,200 COMBOBOX oCbx VAR v_co_cocmbo ITEMS aBase(1,"cust",256,"cu_coun");
  SIZE 110,80 ;
  OF oDlg PIXEL ;
ON CHANGE ( oGet:VarPut( PADR( v_co_cocmbo, 30 ) ),; 
oGet:Refresh(),oDlg:Refresh());
  valid ( reset( v_co_cocmbo, oCbx2, "cust","cu_city","cu_coun" ) , .t. )



  @ 60,2 SAY "&City" OF oDlg PIXEL
  @ 60,50 SAY ":" OF oDlg PIXEL
  @ 60,60 GET oGet2 VAR V_cu_city OF oDlg PIXEL
  @ 60,200 COMBOBOX oCbx2 VAR v_ci_cocmbo ITEMS aItems size 110,80 ;
  OF oDlg PIXEL;
ON CHANGE ( oGet2:VarPut( PADR( v_ci_cocmbo, 30 ) ),; 
oGet2:Refresh(),oDlg:Refresh());
  VALID (reset( v_ci_cocmbo, oCbx3, "cust","cu_gove","cu_city" ), .t.)

  @ 75,2 SAY "&Governer" OF oDlg PIXEL
  @ 75,50 SAY ":" OF oDlg PIXEL
@ 75,60 GET oGet3 VAR V_cu_gove OF oDlg PIXEL
  @ 75,200 COMBOBOX oCbx3 VAR v_go_cocmbo ITEMS aItems  size 110,80 ;
     OF oDlg PIXEL;
ON CHANGE ( oGet3:VarPut( PADR( v_go_cocmbo, 30 ) ),; 
oGet3:Refresh(),oDlg:Refresh())




   @ 95,2 SAY "&Phone" OF oDlg PIXEL
   @ 95,50 SAY ":" OF oDlg PIXEL
   @ 95,60 GET V_CU_phon OF oDlg PIXEL

   @ 115,2 SAY "&Fax" OF oDlg PIXEL
   @ 115,50 SAY ":" OF oDlg PIXEL
   @ 115,60 GET V_CU_fax OF oDlg PIXEL

   @ 130,2 SAY "Man" OF oDlg PIXEL
   @ 130,50 SAY ":" OF oDlg PIXEL
   @ 130,60 GET V_CU_MAN OF oDlg PIXEL

   @ 145,2 SAY "Mobile" OF oDlg PIXEL
   @ 145,50 SAY ":" OF oDlg PIXEL
   @ 145,60 GET V_CU_mobi OF oDlg PIXEL

   @ 160,2 SAY "Account Name" OF oDlg PIXEL
   @ 160,50 SAY ":" OF oDlg PIXEL
   @ 160,60 GET V_CU_appr OF oDlg PIXEL

   @ 280,  9 BUTTON "&Save"  OF oDlg PIXEL SIZE 50, 12 ACTION ( lSave := .t. , oDlg:End() )
   @ 280, 280 BUTTON "&Cancel" OF oDlg PIXEL SIZE 50, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   if lSave .and. !empty( V_CU_ACCT )

      if lAppend
         select 1
         use cust
         APPEND BLANK
      else
         select 1
         use cust
         GOTO nOldRec
      endif

cust->CU_ACCT :=V_CU_ACCT
cust->CU_NAME :=V_CU_NAME
cust->cu_coun :=V_cu_coun
cust->cu_city :=V_cu_city
cust->cu_gove :=V_cu_gove
cust->cu_stre :=V_cu_stre
cust->CU_phon :=V_CU_phon
cust->CU_fax  :=V_CU_fax
cust->CU_MAN  :=V_CU_MAN
cust->CU_mobi :=V_CU_mobi
cust->CU_appr :=V_CU_appr

      oLbx:Refresh()          // We want the ListBox to be repainted

   else


      if Empty( V_CU_ACCT ) .and. lSave
         MsgAlert( "Please write an contract account number " )
      endif

      select 1
      use cust
      set index to cust
      oLbx:Refresh()          // We want the ListBox to be repainted

      GOTO nOldRec

   endif

      select 1
      use cust
      set index to cust
      oLbx:Refresh()          // We want the ListBox to be repainted

      GOTO nOldRec

return nil

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Ehab,

Code: Select all

*use cust 
Its commented out in your code.
regards, saludos

Antonio Linares
www.fivetechsoft.com
Ehab Samir Aziz
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Post by Ehab Samir Aziz »

I have error :
Application
===========
Path and name: E:\programs\clipper\FWH\sitex\sitex.exe (32 bits)
Size: 1,464,320 bytes
Time from start: 0 hours 0 mins 22 secs
Error occurred at: 18/07/2006, 21:20:36
Error description: Error BASE/1002 Alias does not exist: CUST
Stack Calls
===========
Called from: => (b)SETFILTER(0)
Called from: => TWBROWSE:DISPLAY(0)
Called from: => TCONTROL:HANDLEEVENT(0)
Called from: => _FWH(0)
Called from: => SYSREFRESH(0)
Called from: => TWINDOW:END(0)
Called from: sitex.prg => (b)EDITCUST(454)

line 454 :
@ 280, 9 BUTTON "&Save" OF oDlg PIXEL SIZE 50, 12 ACTION ( lSave := .t. , oDlg:End() )

Code: Select all

static function editcust( oLbx, lAppend )
*-------------------------------------------
local oDlg
LOCAL oCbx
LOCAL oCbx2
LOCAL oCbx3
Local oGet
Local oGet2
Local oGet3
local h:=0
local V_CU_ACCT
local V_CU_NAME
local V_cu_stre
local V_cu_gove:=space(30)
local V_cu_city:=space(30)
local V_cu_coun:=space(30)
local v_co_cocmbo:=""
local v_ci_cocmbo:=""
local v_go_cocmbo:=""
local a_Fields[1]
local a_Vars[1]
local V_CU_phon
local V_CU_fax
local V_CU_MAN
local V_CU_mobi
local V_CU_appr
local lSave := .f.
local nOldRec := RecNo()
local bFilter := ""
local cFilter := ""
local aItems:={}

   DEFAULT lAppend := .f.

   if lAppend
      GOTO BOTTOM
      SKIP
   endif


select 1
use cust
INDEX ON (cust->cu_acct) TO cust
INDEX ON upper(cust->cu_name) TO cust1
INDEX ON upper(cust->cu_coun) TO cust2
INDEX ON upper(cust->cu_city) TO cust3
INDEX ON upper(cust->cu_gove) TO cust4
INDEX ON upper(cust->cu_stre) TO cust5
INDEX ON upper(cust->cu_phon) TO cust6
INDEX ON upper(cust->cu_fax ) TO cust7
INDEX ON upper(cust->cu_mobi) TO cust8
INDEX ON upper(cust->cu_man ) TO cust9
INDEX ON upper(cust->cu_appr) TO cust10
set INDEX TO cust


goto nOldRec
V_CU_ACCT:=cust->CU_ACCT
V_CU_NAME:=cust->CU_NAME
V_cu_coun:=cust->CU_coun
V_cu_city:=cust->CU_city
V_cu_gove:=cust->CU_gove
V_CU_stre:=cust->CU_stre
V_CU_phon:=cust->CU_phon
V_CU_fax:=cust->CU_fax
V_CU_MAN:=cust->CU_MAN
V_CU_mobi:=cust->CU_mobi
V_CU_appr:=cust->CU_appr

DEFINE DIALOG oDlg FROM 8, 2 TO 600, 700 PIXEL ;
TITLE If( lAppend, "New Customer", "Customer Update" )


   @ 1,2 SAY "&Account No." OF oDlg PIXEL 
   @ 1,50 SAY ":" OF oDlg PIXEL 
   @ 1,60 GET V_CU_ACCT OF oDlg PIXEL 

   @ 15,1 SAY "&Name" OF oDlg PIXEL
   @ 15,50 SAY ":" OF oDlg PIXEL
   @ 15,60 GET V_CU_NAME OF oDlg PIXEL

   @ 30,2 SAY "&Street" OF oDlg PIXEL
   @ 30,50 SAY ":" OF oDlg PIXEL
   @ 30,60 GET V_cu_stre OF oDlg PIXEL

  @ 45,2 SAY "&Country" OF oDlg PIXEL
  @ 45,50 SAY ":" OF oDlg PIXEL
  @ 45,60 GET oGet VAR V_cu_coun OF oDlg PIXEL
  @ 45,200 COMBOBOX oCbx VAR v_co_cocmbo ITEMS aBase(1,"cust",256,"cu_coun");
  SIZE 110,80 ;
  OF oDlg PIXEL ;
ON CHANGE ( oGet:VarPut( PADR( v_co_cocmbo, 30 ) ),; 
oGet:Refresh(),oDlg:Refresh());
  valid ( reset( v_co_cocmbo, oCbx2, "cust","cu_city","cu_coun" ) , .t. )



  @ 60,2 SAY "&City" OF oDlg PIXEL
  @ 60,50 SAY ":" OF oDlg PIXEL
  @ 60,60 GET oGet2 VAR V_cu_city OF oDlg PIXEL
  @ 60,200 COMBOBOX oCbx2 VAR v_ci_cocmbo ITEMS aItems size 110,80 ;
  OF oDlg PIXEL;
ON CHANGE ( oGet2:VarPut( PADR( v_ci_cocmbo, 30 ) ),; 
oGet2:Refresh(),oDlg:Refresh());
  VALID (reset( v_ci_cocmbo, oCbx3, "cust","cu_gove","cu_city" ), .t.)

  @ 75,2 SAY "&Governer" OF oDlg PIXEL
  @ 75,50 SAY ":" OF oDlg PIXEL
@ 75,60 GET oGet3 VAR V_cu_gove OF oDlg PIXEL
  @ 75,200 COMBOBOX oCbx3 VAR v_go_cocmbo ITEMS aItems  size 110,80 ;
     OF oDlg PIXEL;
ON CHANGE ( oGet3:VarPut( PADR( v_go_cocmbo, 30 ) ),; 
oGet3:Refresh(),oDlg:Refresh())




   @ 95,2 SAY "&Phone" OF oDlg PIXEL
   @ 95,50 SAY ":" OF oDlg PIXEL
   @ 95,60 GET V_CU_phon OF oDlg PIXEL

   @ 115,2 SAY "&Fax" OF oDlg PIXEL
   @ 115,50 SAY ":" OF oDlg PIXEL
   @ 115,60 GET V_CU_fax OF oDlg PIXEL

   @ 130,2 SAY "Man" OF oDlg PIXEL
   @ 130,50 SAY ":" OF oDlg PIXEL
   @ 130,60 GET V_CU_MAN OF oDlg PIXEL

   @ 145,2 SAY "Mobile" OF oDlg PIXEL
   @ 145,50 SAY ":" OF oDlg PIXEL
   @ 145,60 GET V_CU_mobi OF oDlg PIXEL

   @ 160,2 SAY "Account Name" OF oDlg PIXEL
   @ 160,50 SAY ":" OF oDlg PIXEL
   @ 160,60 GET V_CU_appr OF oDlg PIXEL

   @ 280,  9 BUTTON "&Save"  OF oDlg PIXEL SIZE 50, 12 ACTION ( lSave := .t. , oDlg:End() )
   @ 280, 280 BUTTON "&Cancel" OF oDlg PIXEL SIZE 50, 12 ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED

   if lSave .and. !empty( V_CU_ACCT )

      if lAppend
         select 1
         use cust index cust->cust
         APPEND BLANK
      else
         select 1
         use cust index cust->cust
         GOTO nOldRec
      endif

cust->CU_ACCT :=V_CU_ACCT
cust->CU_NAME :=V_CU_NAME
cust->cu_coun :=V_cu_coun
cust->cu_city :=V_cu_city
cust->cu_gove :=V_cu_gove
cust->cu_stre :=V_cu_stre
cust->CU_phon :=V_CU_phon
cust->CU_fax  :=V_CU_fax
cust->CU_MAN  :=V_CU_MAN
cust->CU_mobi :=V_CU_mobi
cust->CU_appr :=V_CU_appr

      oLbx:Refresh()          // We want the ListBox to be repainted

   else


      if Empty( V_CU_ACCT ) .and. lSave
         MsgAlert( "Please write an contract account number " )
      endif

      select 1
      use cust
      set index to cust
      oLbx:Refresh()          // We want the ListBox to be repainted

      GOTO nOldRec

   endif

      select 1
      use cust
      set index to cust
      oLbx:Refresh()          // We want the ListBox to be repainted

      GOTO nOldRec

return nil

User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Ehab,

Try this:

@ 280, 9 BUTTON "&Save" OF oDlg PIXEL SIZE 50, 12 ACTION ( lSave := .t. , oLbx:cAlias := "", oDlg:End() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Ehab Samir Aziz
Posts: 334
Joined: Fri Oct 14, 2005 1:54 pm

Post by Ehab Samir Aziz »

still same error . I can send sample of program to your private mail to be tested.

Application
===========
Path and name: E:\programs\clipper\FWH\sitex\sitex.exe (32 bits)
Size: 1,464,320 bytes
Time from start: 0 hours 0 mins 21 secs
Error occurred at: 19/07/2006, 15:44:53
Error description: Error BASE/1002 Alias does not exist

Stack Calls
===========
Called from: => (b)SETFILTER(0)
Called from: => TWBROWSE:DISPLAY(0)
Called from: => TCONTROL:HANDLEEVENT(0)
Called from: => _FWH(0)
Called from: => DIALOGBOXINDIRECT(0)
Called from: => TDIALOG:ACTIVATE(0)
Called from: sitex.prg => LISTCUST(310)
Called from: sitex.prg => (b)BUILDMENU(147)
Called from: => TMENU:COMMAND(0)
Called from: => TWINDOW:COMMAND(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: => _FWH(0)
Called from: => WINRUN(0)
Called from: => TWINDOW:ACTIVATE(0)
Called from: sitex.prg => MAIN(133)
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Ehab,

It looks like you are closing and then reopening the cust file while oLbx is still running. This will cause the type of error you are getting.

You really should read my articles on using database classes. You could could cut your code at least in half. With a database class you don't need to create all the local vars, then reassign them back to the database. This all happens automatically with the built-in buffer.

oCust:name:="whatever"
oCust:save()

That's all you need. Also, with a database subclass you can add your own Add and Edit methods and you don't need to keep opening and closing the database.

See the articles at my website (button below).

James
Post Reply