Init Method
Object: frmordhistory
Expand/Collapse source code of procedure Init Source Code
*-- (c) Microsoft Corporation 1995

LPARAMETERS toOrdEntryForm
LOCAL lnNumParms, ;
      lcFilter, i, ;
      loCustomerForm, ;
      liDataSession, ;
      lcCustomer_ID, ;
      lcWonTop 

thisform.Left = 11
thisform.Top = 2
thisform.cOriginalFormCaption = thisform.Caption


lnNumParms = PARAMETERS()

*-- Change form's caption and name before calling 
*-- tsBaseForm::Init() to ensure that the proper suffix
*-- has been added to both the name and caption to 
*-- support multiple instances of this form.
*-- Only one instance per order entry form is permitted, so
*-- if this instance is attached to an Order Entry form, 
*-- we won't worry about changing the name caption
IF lnNumParms = 0
  thisform.cOriginalFormName = thisform.Name
  thisform.Name = thisform.Name + ALLT(STR(oApp.AddInstance(thisform)))
  thisform.Caption = thisform.Caption + ":" + ;
                      RIGHT(ALLT(thisform.Name), 1)
ENDIF

tsBaseForm::Init


IF lnNumParms > 0
  thisform.oOrdEntryForm = toOrdEntryForm
  thisform.cmdAddToCurrentOrder.Enabled = .T.
  thisform.Caption = thisform.Caption + ;
                     LOWERFOR_LOC + ;
                     toOrdEntryForm.GetCustomerName()
ELSE
  thisform.cmdAddToCurrentOrder.Enabled = .F.
ENDIF

lcWonTop = LOWER(WONTOP())
FOR i = 1 TO _screen.FormCount
	IF LOWER(_screen.Forms[i].name) == "frmorderentry" AND ;
		lcWonTop == "frmorderentry"
		toOrdEntryForm = _screen.Forms[i]
		EXIT
	ENDIF
	IF LOWER(_screen.Forms[i].name) == "frmcustomers" AND ;
		lcWonTop == "frmcustomers"
		loCustomerForm = _screen.Forms[i]
		EXIT
	ENDIF
NEXT

IF lnNumParms > 0 OR TYPE("toOrdEntryForm ") == 'O'
  *-- use customer number on order entry form
  =SEEK(toOrdEntryForm.GetCustomerID(),"customer","customer_i")
ELSE
  IF TYPE("loCustomerForm") == 'O'
    *-- use customer number on customer form
    liDataSession = THISFORM.datasessionID
    SET DATASESSION TO loCustomerForm.datasessionID
    lcCustomer_ID = customer.customer_id
    SET DATASESSION TO liDataSession
    =SEEK(m.lcCustomer_ID,"customer","customer_i") 
  ENDIF
ENDIF

*- RefreshForm will be called in Activate
THISFORM.grdOrdHistory.RecordSource = "history"
THISFORM.grdLineItems.RecordSource = "cItems"
THISFORM.nOrderRec = RECN("history")