Subject Re: Appending records
From Mattia <mattia@nospam.com>
Date Tue, 26 Sep 2023 02:54:06 -0400
Newsgroups dbase.getting-started

I'm not sure I fully understand the whole situation but...

>    this.expenses2.rowset.append()
>    this.expenses2.rowset.fields["biolinc_on"] = Lc_OrderNo

try with

    FORM.expenses2.rowset.BEGINAPPEND()
    FORM.expenses2.rowset.fields["biolinc_on"].VALUE = Lc_OrderNo
    FORM.expenses2.rowset.SAVE()

I think you are mixing "old commands" and new approach.
I hope someone better than me can help you with more suggestion


Mattia

Rouke Wrote:

> While in a form with:
>
> open database the_linx
> set database to the_linx
>
> ** END HEADER -- do not remove this line
> //
> // Generated on 26/09/2023
> //
> parameter bModal
> local f
> f = new Expense_table_testForm()
> if (bModal)
>    f.mdi = false // ensure not MDI
>    f.readModal()
> else
>    f.open()
> endif
>
> class Expense_table_testForm of FORM
>    with (this)
>       height = 22.8636
>       left = 1.1429
>       top = 4.8636
>       width = 191.2857
>       text = ""
>    endwith
>
>    this.EXPENSES1 = new DATABASE(this)
>    with (this.EXPENSES1)
>       left = 29.0
>       width = 7.0
>       height = 1.0
>       databaseName = "EXPENSES"
>       active = true
>    endwith
>
>    this.EXPENSES2 = new QUERY(this)
>    with (this.EXPENSES2)
>       left = 20.0
>       width = 7.0
>       height = 1.0
>       database = form.expenses1
>       sql = "C:\Users\rouke.bakker\OneDrive - AsureQuality Limited\the_Linx\Expenses\Expenses.sql"
>       active = true
>    endwith
>
> I want to access expenses.dbf to generate the next order number, then leave expenses.dbf again and append a new record to the database and replace field biolinc_on with the newly generated order number.
>
> In Visualdb5.7 I did it this way:
>
>    Use Expenses again in select() alias Expenditures order BioLinc_ON
>    Select Expenditures
>    Set filter to left(Expenditures->BioLinc_ON,3)='AQL'
>    Go bottom
>    Lc_OrderNo = left(BioLinc_ON,3)+str(val(substr(BioLinc_ON,4))+1,4,0,'0')
>    Select Expenses1
>    Append blank
>    Replace Expenses1->BioLinc_ON with Lc_OrderNo
>
> In dBASE 2019 I try:
>    Use Expenses again in select() alias Expenditures order BioLinc_ON
>    Select Expenditures
>    Set filter to left(Expenditures->BioLinc_ON,3)='AQL'
>    Go bottom
>    Lc_OrderNo = left(BioLinc_ON,3)+str(val(substr(BioLinc_ON,4))+1,4,0,'0')
>    this.expenses2.rowset.append()
>    this.expenses2.rowset.fields["biolinc_on"] = Lc_OrderNo
>
> but get the error message: Variable undefined: EXPENSES2
>
> Any help would be much appreciated.
>
> Thanks,
>
> Rouke