Subject Re: autoincrement problem success?
From Mervyn Bick <invalid@invalid.invalid>
Date Thu, 19 Oct 2023 15:05:40 +0200
Newsgroups dbase.getting-started
Attachment(s) test_coins.wfm

On 2023/10/18 18:53, Charlie wrote:
> Think I have fixed this.  When I was running the fixit program I didn't have the correct path to the table.  I just ran it with the correct path and instead of getting lw = 6, it did come up with 293.  Thanks so much for the help I received.  Sorry for my stupid~

I assume you want to use the contents of the LR field so as to be able
to go direct to a specific record in the coins table.  In other words so
as to be able to emulate the RECNO() used in XDML in a GO command.

As an aside, OODML doesn't implement the GO command and the rowset
object's goto() method only works with bookmarks.  If you use an autoinc
field as a primary key in the coins table you will need to use the
rowset's applyLocate() method to move the rowpointer to a specific record.

form.coins1.rowset.applyLocate("lr =
"+form.test_floss1.rowset.fields['rec_no'].value)

A little example form is attached


You stated elsewhere that, because you were having problems with the
autoinc field, you had added the SKU field to the table to use in place
of the LR field.

Be aware that the coins table has three duplicate SKU values so, as it
stands, values in the field can't be used as a primary key to go to one
specific record in the coins table.

sku                   lr
LC1909P               74
LC1909P               76
LC1909S               75
LC1909S               78
LC1922D              114
LC1922D              116

Mervyn.


if file('test_floss.dbf')
// drop table test_floss
endif

if not file('test_floss.dbf')
   create table test_floss  (id autoinc,rec_no integer)
   insert into test_floss  (rec_no) values (74)
   insert into test_floss  (rec_no) values (75)
   insert into test_floss  (rec_no) values (76)
   insert into test_floss  (rec_no) values (78)
   insert into test_floss  (rec_no) values (114)
   insert into test_floss  (rec_no) values (116)
endif

** END HEADER -- do not remove this line
//
// Generated on 2023-10-19
//
parameter bModal
local f
f = new test_coinsForm()
if (bModal)
   f.mdi = false // ensure not MDI
   f.readModal()
else
   f.open()
endif

class test_coinsForm of FORM
   with (this)
      onOpen = class::FORM_ONOPEN
      height = 16.0
      left = 3.7143
      top = 0.5455
      width = 119.8571
      text = ""
   endwith

   this.COINS1 = new QUERY(this)
   with (this.COINS1)
      left = 6.0
      width = 5.0
      height = 1.0
      sql = 'select * from "D:\Examples\Plus2019\COINS.DBF"'
      active = true
   endwith

   this.test_floss1 = new QUERY(this)
   with (this.test_floss1)
      left = 75.0
      top = 1.0
      width = 5.0
      height = 1.0
      sql = 'select * from "D:\Examples\Plus2019\test_floss.DBF"'
      active = true
   endwith

   this.GRID1 = new GRID(this)
   with (this.GRID1)
      dataLink = form.coins1.rowset
      height = 7.5
      left = 4.0
      top = 0.2727
      width = 106.1429
   endwith

   this.GRID2 = new GRID(this)
   with (this.GRID2)
      onSelChange = class::GRID2_ONSELCHANGE
      dataLink = form.test_floss1.rowset
      height = 6.8636
      left = 8.7143
      top = 8.5455
      width = 37.8571
   endwith

   this.ENTRYFIELD1 = new ENTRYFIELD(this)
   with (this.ENTRYFIELD1)
      dataLink = form.coins1.rowset.fields["lr"]
      height = 1.0
      left = 67.7143
      top = 11.1818
      width = 8.0
   endwith

   this.TEXTLABEL1 = new TEXTLABEL(this)
   with (this.TEXTLABEL1)
      height = 1.0
      left = 69.2857
      top = 10.0
      width = 12.0
      text = "LR"
   endwith

   this.rowset = this.coins1.rowset

   function GRID2_onSelChange()
      form.coins1.rowset.applyLocate("lr = "+form.test_floss1.rowset.fields['rec_no'].value)
      return

   function form_onOpen()
      form.coins1.rowset.applyLocate("lr = "+form.test_floss1.rowset.fields['rec_no'].value)
      return

endclass