Page 1 of 2

HELP!

Posted: Tue May 13, 2008 3:00 pm
by davidlim
(1) Customer maintenance program: once I enter the customer code, IF the code exist, I want the program to retrive the information from the customer master file, NAME, ADDRESS, etc ..., and ready for amendment instead of POPUP a selection box for customer selection. THE problem I am facing now was when I enter a customer code and press enter, it will prompt up a selection box for customer selection, no matter the customer exist or not.

Thanks and appreciate for Helps.

Posted: Tue May 13, 2008 6:09 pm
by James Bott
I am not clear. Are you a user or a programmer? Did you write the code or did someone else?

What do you mean by, "eady for amendment." Are you adding customer information to something else, like an order?

Regards,
James

HELP!

Posted: Wed May 14, 2008 12:09 am
by david lim
Is in customer master maintenance. When I enter customer code, if the code already exist in the customer master, I want the program jump to amendment of NAME, ADDRESS, TEL, etc, instead of POPUP a customer selection box. I want to know the command to bypass the POPUP. Thanks and appreciate for your kind attention.

Posted: Wed May 14, 2008 6:19 am
by James Bott
>I want to know the command to bypass the POPUP.

I still don't know if you are a programmer or a user?

If you are a programmer, then we need to see your source code.

If you are user, then what you want is not possible without the source code. Do you have the source code?

Regards,
James

Posted: Wed May 14, 2008 7:00 am
by davidlim
yes, i am programmer, just pick up FWH, quit confuse with DEFINE and REDEFINE, here is the source codes:-

DEFINE DIALOG oDlg RESOURCE "DebtorMaintenance"

REDEFINE GET oGetCode VAR cCode ID 110 OF oDlg Picture "@!"

REDEFINE BTNBMP oBtn1 ID 115 OF oDlg
FILENAME "c:\fwh\bitmaps\search.bmp" ACTION ( SelectCode(
oGetCode, cCode ), oGetName:VarPut( ArCust->Name ) ,;
oGetAdd1:VarPut( ArCust->Add1 ) ,;
oGetAdd2:VarPut( ArCust->Add2 ) ,;
oGetTeln:VarPut( ArCust->Teln ) ,;
oGetFaxn:VarPut( ArCust->Faxn ) ,;
oGetName:Refresh() ,;
oGetAdd1:Refresh() ,;
oGetAdd2:Refresh() ,;
oGetTeln:SetFocus() ,;
oGetFaxn:Refresh() ,;
oGetName:SetFocus() )

REDEFINE GET oGetName VAR cName ID 120 OF oDlg VALID ! Empty(
cName )

REDEFINE GET oGetAdd1 VAR cAdd1 ID 130 OF oDlg

REDEFINE GET oGetAdd2 VAR cAdd2 ID 140 OF oDlg

REDEFINE GET oGetTeln VAR cTeln ID 150 OF oDlg

REDEFINE GET oGetFaxn VAR cFaxn ID 160 OF oDlg

REDEFINE BUTTON ID ID_SAVE OF oDlg ACTION ( lSave := .T.,
oDlg:End() )

REDEFINE BUTTON ID ID_DELETE OF oDlg ACTION ( lDelete := .T.,
oDlg:End() )

REDEFINE BUTTON ID ID_CANCEL OF oDlg ACTION oDlg:End() CANCEL

ACTIVATE DIALOG oDlg CENTERED

...

Thanks and appreciate for your kind attention and help.
_________________
asking for help and willing to help others

Posted: Wed May 14, 2008 7:10 am
by dutch
Dear David,

You must show SelectCode() function. It is the main point you mention.

Regards,
Dutch

HELP!

Posted: Wed May 14, 2008 7:21 am
by david lim
Here is the SelectCode() function:-

...

function SelectCode( oGetCodex, cCodex )

select 1
set softseek on
seek cCodex
set softseek off

ArCust->( DbChoice( "Select a customer", 1 ) )

oGetCodex:VarPut( AllTrim( ArCust->Code ) )

oGetCodex:Refresh() // repaints the GET

return nil

function DbChoice( cTitle, cSelect )

local oDlg, oBrw

DEFINE DIALOG oDlg RESOURCE "DbChoice" TITLE cTitle

if cSelect = 1
REDEFINE LISTBOX oBrw ;
FIELDS ArCust->Code, ArCust->Name ;
HEADERS "Code", "Name" ;
ID 100 OF oDlg
endif

ACTIVATE DIALOG oDlg CENTERED

return nil

...

Thanks and appreciate for your kind attention and help.

NEW METHOD!

Posted: Wed May 14, 2008 8:07 am
by davidlim
Please advise the easier and simple way of doing CUSTOMER MASTER MAINTENANCE (NEW, EDIT, DELETE, SEARCH), Thanks.

Re: HELP!

Posted: Wed May 14, 2008 8:19 am
by dutch
david lim wrote:Here is the SelectCode() function:-

...

function SelectCode( oGetCodex, cCodex )

select 1
* set softseek on
* seek cCodex

Code: Select all

   if ArCust->(DbSeek( cCodex ))
      if ArCust->Code==cCodex
         return nil
      end
   end

* set softseek off

ArCust->( DbChoice( "Select a customer", 1 ) )

oGetCodex:VarPut( AllTrim( ArCust->Code ) )

oGetCodex:Refresh() // repaints the GET

return nil

function DbChoice( cTitle, cSelect )

local oDlg, oBrw

DEFINE DIALOG oDlg RESOURCE "DbChoice" TITLE cTitle

if cSelect = 1
REDEFINE LISTBOX oBrw ;
FIELDS ArCust->Code, ArCust->Name ;
HEADERS "Code", "Name" ;
ID 100 OF oDlg
endif

ACTIVATE DIALOG oDlg CENTERED

return nil

...

Thanks and appreciate for your kind attention and help.

HELP!

Posted: Wed May 14, 2008 11:08 am
by davidlim
Thanks & appreciate for kind attention and help.

. . .

DEFINE DIALOG oDlg RESOURCE "DebtorMaintenance"

REDEFINE GET oGetCode VAR cCode ID 110 OF oDlg Picture "@!"

REDEFINE BTNBMP oBtn1 ID 115 OF oDlg
FILENAME "c:\fwh\bitmaps\search.bmp" ACTION ( SelectCode(
oGetCode, cCode ), oGetName:VarPut( ArCust->Name ) ,;
oGetAdd1:VarPut( ArCust->Add1 ) ,;
. . .
oGetEmai:Refresh() ,;
oGetReps:Refresh() , oGetName:SetFocus() )

REDEFINE GET oGetName VAR cName ID 120 OF oDlg VALID ! Empty
( cName )

REDEFINE GET oGetAdd1 VAR cAdd1 ID 130 OF oDlg

. . .

function SelectCode( oGetCodex, cCodex )
if Empty( cCodex )
DbGoTop()
ArCust->( DbChoice( "Select a customer", 1 ) )
else
Select 1
ArCust->( DbSeek( cCodex ) )
if ArCust->Code==cCodex
return nil
else
set softseek on
seek cCodex
set softseek off
ArCust->( DbChoice( "Select a customer", 1 ) )
endif
endif

oGetCodex:VarPut( ArCust->Code )
oGetCodex:Refresh()
return nil


(1) would like to find out WHY empty customer code still valid to save?
(2) for DbChoice, to select a customer, HOW to activate an enter key instead of click on OK button for selection?

Re: HELP!

Posted: Wed May 14, 2008 4:31 pm
by dutch
Dear David,

Pls try this.
davidlim wrote:Thanks & appreciate for kind attention and help.

. . .

DEFINE DIALOG oDlg RESOURCE "DebtorMaintenance"

* REDEFINE GET oGetCode VAR cCode ID 110 OF oDlg Picture "@!"

Code: Select all

      REDEFINE GET oGetCode VAR cCode ID 110 OF oDlg Picture "@!"  ;
                     VALID (if(empty(cCode),.F.,(SelectCode( oGetCode, cCode ),.T.))
          
REDEFINE BTNBMP oBtn1 ID 115 OF oDlg
FILENAME "c:\fwh\bitmaps\search.bmp" ACTION ( SelectCode(
oGetCode, cCode ), oGetName:VarPut( ArCust->Name ) ,;
oGetAdd1:VarPut( ArCust->Add1 ) ,;
. . .
oGetEmai:Refresh() ,;
oGetReps:Refresh() , oGetName:SetFocus() )

REDEFINE GET oGetName VAR cName ID 120 OF oDlg VALID ! Empty
( cName )

REDEFINE GET oGetAdd1 VAR cAdd1 ID 130 OF oDlg

Code: Select all

REDEFINE BUTTON ID ID_SAVE OF oDlg WHEN !empty(cCode) ;
ACTION ( lSave := .T., oDlg:End() ) 
. . .

function SelectCode( oGetCodex, cCodex )
if Empty( cCodex )
DbGoTop()
ArCust->( DbChoice( "Select a customer", 1 ) )
else
Select 1
ArCust->( DbSeek( cCodex ) )
if ArCust->Code==cCodex
return nil
else
set softseek on
seek cCodex
set softseek off
ArCust->( DbChoice( "Select a customer", 1 ) )
endif
endif

oGetCodex:VarPut( ArCust->Code )
oGetCodex:Refresh()
return nil


(1) would like to find out WHY empty customer code still valid to save?
(2) for DbChoice, to select a customer, HOW to activate an enter key instead of click on OK button for selection?
Regards,
Dutch

THANKS

Posted: Wed May 14, 2008 10:12 pm
by davidlim
Thanks and appreciate for your kind attention and help, DUTCH.

HELP!

Posted: Wed May 14, 2008 10:22 pm
by davidlim
i got 20+ programming years (start from programmer -> analyst programmer -> systems analyst -> project manager -> software developer). program logic and data flow are totally not a problem to me, but why i still can't manage to solve this simple customer master maintenance program in gui environment! i am so sorry, but i really need helping hand from all of you. THANKS AND APPRECIATE TO ALL OF YOU.

Posted: Wed May 14, 2008 10:31 pm
by James Bott
David,

I have written some articles about programming in FW which may help. They are available on my website here:

http://ourworld.compuserve.com/homepage ... rogram.htm

Regards,
James

HELP!

Posted: Wed May 14, 2008 10:36 pm
by davidlim
i did follow what DUTCH show me,
(1) BUT when the 1st screen come out, ask for customer code, i just press enter without keying anything, the program end without saving the empty record.
(2) IF i enter any character, like A or Z, and press enter, it will simply save the record and end the program.
(3) the customer code i set to 8 characters, if i entered all the 8 characters and the focus go to next SEARCH button, it will now popup customer selection

where and what missing?