Get a Jumpstart with our Sample Apps
Results 1 to 7 of 7

Thread: Create a record and fill one of the fields with a variable

  1. #1
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    3,809

    Default Create a record and fill one of the fields with a variable

    Is there a better way than tbl.enter_begin etc to create a new record in a table and fill one of the fields with a variable?
    Ted Giles
    Example Consulting - UK
    .

    https://exampleltd.example-software.com/

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,697

    Default Re: Create a record and fill one of the fields with a variable

    Define "better".

    There is

    RECORD_ADD( Table_Name as C, Data_List as C [, Style as N )
    There can be only one.

  3. #3
    "Certified" Alphaholic Ted Giles's Avatar
    Real Name
    Ted Giles
    Join Date
    Aug 2000
    Location
    In the Wolds, Louth, Lincolnshire, UK
    Posts
    3,809

    Default Re: Create a record and fill one of the fields with a variable

    Thank you Stan.
    I tried that earlier and got an error msg trying to incorporate the variable.
    Ted Giles
    Example Consulting - UK
    .

    https://exampleltd.example-software.com/

  4. #4
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,697

    Default Re: Create a record and fill one of the fields with a variable

    Using style 1 or 2? Either works here but style 1 requires more effort.

    Code:
    idcode = "123"
    v1code = 7
    v2code = 9
    dim cs as C
    cs = "id ="+idcode + crlf() + "v1 = "+s_quote(v1code) + crlf() + "v2 = "+s_quote(v2code)
    ? record_add("atest", cs, 1)
    = .T.
    There can be only one.

  5. #5
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Re: Create a record and fill one of the fields with a variable

    Style 1 looks like you ought to be able to create a
    data = <<%str% ... %str%
    Because otherwise using Style 2, wouldn't you need to know the field order? So if you only wanted to fill in say Field 3 then Fields 1-2 would need to be set to blank (?)
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    24,697

    Default Re: Create a record and fill one of the fields with a variable

    Using style 1 you can use the <<%str%...%str% syntax but then you have to get the variables values into the data string. Not really much difference.

    Code:
    idcode = "123"
    v1code = 7
    v2code = 9
    dim cs as C
    cs = <<%str%
    id = first_fld
    v2 = another_field
    %str%
    cs = strtran(cs,"first_fld",var->idcode)
    cs = strtran(cs,"another_field",s_quote(var->v2code))
    ? record_add("atest", cs, 1)
    = .T.
    There can be only one.

  7. #7
    "Certified" Alphaholic MoGrace's Avatar
    Real Name
    Robin
    Join Date
    Mar 2006
    Location
    Los Angeles
    Posts
    3,211

    Default Re: Create a record and fill one of the fields with a variable

    Ah yes, I keep forgetting about STRTRAN().
    Robin

    Discernment is not needed in things that differ, but in those things that appear to be the same. - Miles Sanford

Similar Threads

  1. Create a Duplicate Record with only some fields filled in
    By amandavogt in forum Windows Desktop Applications
    Replies: 2
    Last Post: 08-13-2015, 03:06 PM
  2. Look up and fill in fields, filling to a variable.
    By Islip in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 07-26-2011, 04:33 PM
  3. fill fields from another table, break down fields
    By FreeBird in forum Alpha Five Version 10 - Desktop Applications
    Replies: 4
    Last Post: 06-13-2010, 02:39 AM
  4. Is lookup the right choice to select & fill fields with 2 fields
    By MikeData in forum Alpha Five Version 9 - Desktop Applications
    Replies: 13
    Last Post: 01-10-2009, 05:21 PM
  5. Fill variable with browse value
    By Tom Patten in forum Alpha Five Version 4
    Replies: 5
    Last Post: 05-26-2005, 07:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •