Alpha DevCon 2018
Results 1 to 8 of 8

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
    4,016

    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/
    See our site for Alpha Support, Conversion and Upgrade.

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

    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
    4,016

    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/
    See our site for Alpha Support, Conversion and Upgrade.

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

    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,408

    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
    25,011

    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,408

    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

  8. #8
    "Certified" Alphaholic DaveM's Avatar
    Real Name
    Dave Mason
    Join Date
    Jul 2000
    Location
    Hudson, FL
    Posts
    5,894

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

    You can do it by adding a value to a field on field enter,
    'Set 'Value' property of 'Add' in Form 'dotimes' .
    parentform:Add.value = convert_type(time,"character")
    This was done by alpha and converted to xbasic. time would not have been correct for address field.
    Dave Mason
    dave@aldaweb.com

    Skype is dave.mason46

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, 02: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, 03: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, 01: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, 04:21 PM
  5. Fill variable with browse value
    By Tom Patten in forum Alpha Five Version 4
    Replies: 5
    Last Post: 05-26-2005, 06:25 PM

Bookmarks

Posting Permissions

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