Subject Re: grid focus
From Ken Mayer <dbase@nospam.goldenstag.net>
Date Thu, 29 Dec 2022 12:55:45 -0800
Newsgroups dbase.getting-started
Attachment(s) ghor.wfm

On 12/29/2022 12:54 PM, Ken Mayer wrote:
> On 12/29/2022 11:43 AM, Mustansir Ghor wrote:
>> Dear Ken Sir
>>
>> By putting this.setfocus() on Escan_lonostfocus() will jammed the form
>> as than the focus will remain fowever at entryfield.
>
> Only if the value is empty -- look at where I put it -- inside the case
> structure ...

Followup, I did test it before I posted ... see attached.

Ken

--
*Ken Mayer*
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm
dBASE DOS to Windows Tutorial:
http://www.goldenstag.net/dbase/DtoWTutorial/00_Menu.htm





** END HEADER -- do not remove this line
//
// Generated on 12/29/2022
//
parameter bModal
local f
f = new ghorForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class ghorForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 23.28
      left = 8.375
      top = -0.12
      width = 126.375
      text = ""
   endwith

   this.QSALES = new QUERY(this)
   with (this.QSALES)
      left = 15.0
      top = 1.0
      width = 4.0
      height = 1.0
      sql = "select * from sales where sno=:msno"
      params["msno"] = ""
      active = true
   endwith

   with (this.QSALES.rowset)
      onNavigate = class::ROWSET_ONNAVIGATE
   endwith

   this.QTEMPSAL = new QUERY(this)
   with (this.QTEMPSAL)
      left = 21.0
      width = 6.0
      height = 1.0
      sql = "select distinct sno,sdate,op from sales where sdate between :mdate1 and :mdate2"
      params["mdate1"] = {12/28/2022}
      params["mdate2"] = {12/28/2022}
      active = true
   endwith

   with (this.QTEMPSAL.rowset)
      onNavigate = class::ROWSET_ONNAVIGATE1
   endwith

   this.LINE3 = new LINE(this)
   with (this.LINE3)
      left = 68.0
      right = 68.0
      top = 3.0
      bottom = 22.0
      width = 1
   endwith

   this.PBCLOSE = new PUSHBUTTON(this)
   with (this.PBCLOSE)
      onClick = class::PBCLOSE_ONCLICK
      height = 1.5
      left = 48.0
      top = 18.5
      width = 16.0
      text = "Close The Form"
      fontName = "Calibri"
      fontSize = 12.0
   endwith

   this.GRID2 = new GRID(this)
   with (this.GRID2)
      fontName = "Calibri"
      fontSize = 12.0
      headingFontName = "Calibri"
      headingFontSize = 12.0
      dataLink = form.qtempsal.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.GRID2)
      with (columns["COLUMN1"])
         dataLink = form.qtempsal.rowset.fields["sno"]
         editorType = 1        // EntryField
         width = 8.625
      endwith
      columns["COLUMN2"] = new GRIDCOLUMN(form.GRID2)
      with (columns["COLUMN2"])
         dataLink = form.qtempsal.rowset.fields["sdate"]
         editorType = 1        // EntryField
         width = 12.0
      endwith
      columns["COLUMN4"] = new GRIDCOLUMN(form.GRID2)
      with (columns["COLUMN4"])
         dataLink = form.qtempsal.rowset.fields["op"]
         editorType = 1        // EntryField
         width = 11.375
      endwith
      with (columns["COLUMN1"].editorControl)
         fontName = ""
      endwith

      with (columns["COLUMN1"].headingControl)
         fontName = ""
         value = "SNO"
      endwith

      with (columns["COLUMN2"].editorControl)
         fontName = ""
      endwith

      with (columns["COLUMN2"].headingControl)
         fontName = ""
         value = "DATE"
      endwith

      with (columns["COLUMN4"].editorControl)
         fontName = ""
      endwith

      with (columns["COLUMN4"].headingControl)
         fontName = ""
         value = "OPERATOR"
      endwith

      allowEditing = false
      allowAddRows = false
      height = 13.5
      left = 24.0
      top = 3.5
      width = 40.0
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      fontName = "Calibri"
      fontSize = 13.0
      headingFontName = "Calibri"
      headingFontSize = 12.0
      dataLink = form.qsales.rowset
      columns["COLUMN1"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN1"])
         dataLink = form.qsales.rowset.fields["code"]
         editorType = 1        // EntryField
         width = 22.0
      endwith
      columns["COLUMN2"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN2"])
         dataLink = form.qsales.rowset.fields["qty"]
         editorType = 1        // EntryField
         width = 10.625
      endwith
      columns["COLUMN5"] = new GRIDCOLUMN(form.GRID1)
      with (columns["COLUMN5"])
         dataLink = form.qsales.rowset.fields["verify"]
         editorType = 1        // EntryField
         width = 12.25
      endwith
      with (columns["COLUMN1"].editorControl)
         fontName = ""
      endwith

      with (columns["COLUMN1"].headingControl)
         fontName = ""
         value = "CODE"
      endwith

      with (columns["COLUMN2"].editorControl)
         picture = "999,999"
         fontName = ""
      endwith

      with (columns["COLUMN2"].headingControl)
         fontName = ""
         value = "QTY"
      endwith

      with (columns["COLUMN5"].editorControl)
         fontName = ""
      endwith

      with (columns["COLUMN5"].headingControl)
         fontName = ""
         value = "VERIFIED BY"
      endwith

      allowEditing = false
      allowAddRows = false
      height = 17.5
      left = 69.0
      top = 3.0
      width = 53.0
   endwith

   this.ESCAN = new ENTRYFIELD(this)
   with (this.ESCAN)
      onLostFocus = class::ESCAN_ONLOSTFOCUS
      onChange = class::ESCAN_ONCHANGE
      visible = false
      height = 1.0
      left = 102.0
      top = 21.0
      width = 20.0
      fontName = "Calibri"
      fontSize = 12.0
      value = ""
   endwith

   this.LBSCAN = new TEXTLABEL(this)
   with (this.LBSCAN)
      visible = false
      height = 1.0
      left = 71.0
      top = 21.0
      width = 31.0
      text = "For this item verification , Scan Here"
      fontName = "Calibri"
      fontSize = 12.0
   endwith


        
  
        

   function PBCLOSE_onClick()
        
      close databases
                form.close()
        
      return


   function form_onOpen()
     with (this)
    
      //height = 24.5909
      left = 1.7143
      top = 4.0
      //width = 179
    
     endwith
            
                form.qtempsal.active=true        
                if form.qtempsal.rowset.count()>0
                 form.qtempsal.rowset.first()
                 form.qsales.active=true
                endif
  
        
        
      return
                


      function ESCAN_onChange()
      
      this.keyboard("{Tab}")
                class::escan_onlostfocus()
                
      return

   function ESCAN_onLostFocus()
? "Escan_onLostFocus()"
           do case
                
                case empty(this.value)
this.setFocus()                
                
                case not form.qsales.rowset.fields["CODE"].lookuprowset.fields["code"].value==this.value and ;
                 empty(form.qsales.rowset.fields["VERIFY"].value)
                
       msgbox("Scan Code Unmatched","",48)
                 form.qsales.rowset.next()

            if form.qsales.rowset.endofset
                 form.lbscan.visible=false
                 form.escan.visible=false
                
                 form.grid2.setfocus()
                 endif
        
                
      case  form.qsales.rowset.fields["CODE"].lookuprowset.fields["code"].value==this.value
                 form.qsales.rowset.fields["VERIFY"].value=_app.session.user()
                 form.qsales.rowset.save()
                
            form.qsales.rowset.next()

            if form.qsales.rowset.endofset
                 form.lbscan.visible=false
                 form.escan.visible=false
                
                 form.grid2.setfocus()
                 endif
                
                endcase
      return


   function rowset_onNavigate(type, nRows)
          
      pref = this.parent.parent
                if this.endofset
                 pref.grid2.setfocus()
                 return
                endif
                
                pref.escan.value=""
                if empty(this.fields["verify"].value)
                 pref.lbscan.visible=true
                 pref.escan.visible=true
                 pref.escan.setfocus()
                else
                 pref.lbscan.visible=false
                 pref.escan.visible=false
                endif
                
      return

   function rowset_onNavigate1(type, nRows)
      this.parent.parent.qsales.params["msno"]=this.fields["sno"].value
           this.parent.parent.qsales.requery()
                this.parent.parent.qsales.rowset.first()
                oref = this.parent.parent
                do while not oref.qsales.rowset.endofset
                 if not empty(oref.qsales.rowset.fields["verify"].value)
                  oref.qsales.rowset.next()
                 else
                  exit
                 endif
                enddo
     return

endclass