Groups > dBase > Getting Started with dBase > Re: updatecombobox




firstrecord

firstrecord
Tue, 11 Mar 2008 14:17:53 -050
Post Reply
Re: firstrecord
Tue, 11 Mar 2008 15:26:20 -040
In article <uv98ay6gIHA.2000@news-server>, guitarbluescharlie@yahoo.com 
says...
> when my form opens, i would like it to be at the first record

If that's necessary, you could add something in the Form's onOpen() 
event-handler a line that says:
   Form.rowset.first()

In the form below, that's not needed but I have added the code anyway to 
show how that's done.

Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Blue Star dBASE Plus Core Concepts Graduate

=========== Start of Charles.wfm =====

if not file('Charles.dbf')
  create table Charles (Numero  autoinc,;
                        ScrambledText char(30) )
  use Charles exclusive
  index on ScrambledText tag ScrambledText
  use Charles
  generate(200)
  use   // Close the table
endif

** END HEADER -- do not remove this line
//
// Generated on 2008/03/11
//
parameter bModal
local f
f = new CharlesForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class CharlesForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 15.6364
      left = 19.7143
      top = 2.6818
      width = 77.8571
      text = ""
   endwith

   this.Charles1 = new QUERY()
   this.Charles1.parent = this
   with (this.Charles1)
      left = 32.8571
      top = 12.6364
      sql = 'select * from "Charles.DBF"'
      active = true
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.Charles1.rowset
      rowSelect = true
      height = 11.3636
      left = 5.5714
      top = 1.1818
      width = 65.0
   endwith

   this.PUSHBUTTON1 = new PUSHBUTTON(this)
   with (this.PUSHBUTTON1)
      onClick = class::PUSHBUTTON1_ONCLICK
      height = 1.1818
      left = 54.7143
      top = 13.0909
      width = 15.8571
      text = "Previous"
   endwith

   this.rowset = this.Charles1.rowset

   function form_onOpen
      Form.rowset.first()
      return

   function PUSHBUTTON1_onClick
      if Form.rowset.atFirst()
         msgBox("You're already at the first
record","Error",64)
      else
         Form.rowset.next(-1)
      endif
      return

Post Reply
Re: updatecombobox
Fri, 14 Mar 2008 12:25:54 -050
Jean-Pierre Martel Wrote:

> In article <uv98ay6gIHA.2000@news-server>,
guitarbluescharlie@yahoo.com 
> says...
> > when my form opens, i would like it to be at the first record
> 
> If that's necessary, you could add something in the Form's onOpen() 
> event-handler a line that says:
>    Form.rowset.first()
> 
> In the form below, that's not needed but I have added the code anyway to 
> show how that's done.
> 
> Jean-Pierre Martel, editor
> The dBASE Developers Bulletin
> Blue Star dBASE Plus Core Concepts Graduate
> 
> =========== Start of Charles.wfm =====
> 
> if not file('Charles.dbf')
>   create table Charles (Numero  autoinc,;
>                         ScrambledText char(30) )
>   use Charles exclusive
>   index on ScrambledText tag ScrambledText
>   use Charles
>   generate(200)
>   use   // Close the table
> endif
> 
> ** END HEADER -- do not remove this line
> //
> // Generated on 2008/03/11
> //
> parameter bModal
> local f
> f = new CharlesForm()
> if (bModal)
>    f.mdi = false // ensure not MDI
>    f.readModal()
> else
>    f.open()
> endif
> 
> class CharlesForm of FORM
>    with (this)
>       onOpen = class::FORM_ONOPEN
>       height = 15.6364
>       left = 19.7143
>       top = 2.6818
>       width = 77.8571
>       text = ""
>    endwith
> 
>    this.Charles1 = new QUERY()
>    this.Charles1.parent = this
>    with (this.Charles1)
>       left = 32.8571
>       top = 12.6364
>       sql = 'select * from "Charles.DBF"'
>       active = true
>    endwith
> 
>    this.GRID1 = new GRID(this)
>    with (this.GRID1)
>       dataLink = form.Charles1.rowset
>       rowSelect = true
>       height = 11.3636
>       left = 5.5714
>       top = 1.1818
>       width = 65.0
>    endwith
> 
>    this.PUSHBUTTON1 = new PUSHBUTTON(this)
>    with (this.PUSHBUTTON1)
>       onClick = class::PUSHBUTTON1_ONCLICK
>       height = 1.1818
>       left = 54.7143
>       top = 13.0909
>       width = 15.8571
>       text = "Previous"
>    endwith
> 
>    this.rowset = this.Charles1.rowset
> 
>    function form_onOpen
>       Form.rowset.first()
>       return
> 
>    function PUSHBUTTON1_onClick
>       if Form.rowset.atFirst()
>          msgBox("You're already at the first
record","Error",64)
>       else
>          Form.rowset.next(-1)
>       endif
>       return
> 
> endclass

first record seems to work - thank you

updating the combobox
when my form opens it is on the first record. if i use first, next, prev, or
last buttons it goes to those records. i would next like to choose an id form
the combobox and have it attached to the correct record. i would like it to also
update the combobox when i save it. right know i have to exit the form and then
return to the form for it to save to the combobox. this combobox has an
entryfield on top of it, it is on a notebook, and there is one of these on page
1 and 2.

snippet :
this.rowset = this.query1.rowset

   function P_TELE_ID_ENTRYFIELD_01_onLostFocus
      form.PER_TELE_NOTEBOOK_00.P_tele_id_entryfield_01.value:=this.value
      form.per_tele_notebook_00.p_tele_id_entryfield_02.value:=this.value
      return

   function P_TELE_ID_ENTRYFIELD_02_onLostFocus
       form.per_tele_notebook_00.p_tele_id_entryfield_01.value:=this.value
      form.per_tele_notebook_00.p_tele_id_entryfield_02.value:=this.value
      return

   function P_T_ADD_C1_PB_00_onClick
      form.rowset.beginAppend()
      return

   function P_T_CANCEL_C3_PB_00_onClick
      if msgbox ( "ABANDON CHANGES TO THIS ROW ?", "ABANDON
CHANGES ?", 36 ) == 6
      form.rowset.abandon()
      endif
      return

   function P_T_DELETE_C3_PB_00_onClick
      if msgbox ( "DELETE THIS ROW ?", "DELETE ROW ?", 36 )
== 6
      form.rowset.delete()
      endif
      return

   function P_T_EDIT_C1_PB_00_onClick
      form.rowset.BeginEdit()
      return

   function P_T_EXIT_C1_PB_00_onClick
      form.close()
      return

   function P_T_FIRST_C2_PB_00_onClick
      form.rowset.first()
      if form.rowset.first()
      msgbox("YOUR ALREADY AT THE FIRST RECORD
!","ERROR",64)
      else
      form.rowset.next(-1)
      endif
      return

   function P_T_ID_COMBOBOX_01_onChange
      form.PER_TELE_NOTEBOOK_00.P_tele_id_entryfield_01.value:=this.value
      form.per_tele_notebook_00.p_tele_id_entryfield_02.value:=this.value
      return

   function P_T_ID_COMBOBOX_01_onLostFocus
      form.per_tele_notebook_00.p_tele_id_entryfield_01.value:=this.value
      form.per_tele_notebook_00.p_tele_id_entryfield_02.value:=this.value
      return

   function P_T_ID_COMBOBOX_02_onChange
      form.per_tele_notebook_00.p_tele_id_entryfield_01.value:=this.value
      form.per_tele_notebook_00.p_tele_id_entryfield_02.value:=this.value
      return

   function P_T_ID_COMBOBOX_02_onLostFocus
      form.per_tele_notebook_00.p_tele_id_entryfield_01.value:=this.value
      form.per_tele_notebook_00.p_tele_id_entryfield_02.value:=this.value
      return

   function P_T_LAST_C2_PB_00_onClick
      if form.rowset.last()
      msgbox("YOUR AT THE LAST RECORD !","ERROR",64)
      else
      form.rowset.next(1)
      endif
      return

   function P_T_NEXT_C2_PB_00_onClick
      if ( not form.rowset.next() )
      msgbox ( "AT END OF ROWSET", "CAN'T NAVIGATE", 64 )
      endif
      return

   function P_T_PREV_C2_PB_00_onClick
      if ( not form.rowset.next(-1) )
      form.rowset.first()
      msgbox ( "AT BEGINNING OF ROWSET", "CAN'T NAVIGATE",
64 )
      endif
      return

   function P_T_SAVE_C3_PB_00_onClick
      form.rowset.save()
      return

   function P_T_SPINBOX_01_onOpen
      this.value := DATE()
      return

   function form_onAppend
      now = new date()
      hours = now.gethours()
      minutes = now.getminutes()
      timevalue = "" + iif((hours>12) , hours - 12 , hours)
      timevalue += iif((minutes <10) , ":0" , ":") +
minutes
      timevalue += iif((hours>=12) , " PM" , " AM")
      this.PER_TELE_NOTEBOOK_00.P_T_TIME_ENTRYFIELD_01.value := timevalue
      form.PER_TELE_NOTEBOOK_00.P_T_SPINBOX_01.VALUE := NOW
      return

   function form_onOpen
      now = new date()
      hours = now.gethours()
      minutes = now.getminutes()
      timevalue = "" + iif((hours>12) , hours - 12 , hours)
      timevalue += iif((minutes <10) , ":0" , ":") +
minutes
      timevalue += iif((hours>=12) , " PM" , " AM")
      this.PER_TELE_NOTEBOOK_00.P_T_TIME_ENTRYFIELD_01.value := timevalue
      form.rowset.first()
      return

   function rowset_onAppend
      this.fields["p_state"].value :="CT"
      return

endclass

Post Reply
Re: updatecombobox
Fri, 14 Mar 2008 16:51:56 -040
In article <w0DG1hfhIHA.384@news-server>, guitarbluescharlie@yahoo.com 
says...
> 
> right know i have to exit the form and then return to the
> form for it to save to the combobox.

How about a...
   Form.rowset.refreshControls()
...to update all the controls connected to the rowset.

Jean-Pierre Martel, editor
The dBASE Developers Bulletin
Post Reply
about | contact