Alpha Video Training
Results 1 to 16 of 16

Thread: Inserting data from one form into multiple tables

  1. #1
    Page Sands
    Guest

    Default Inserting data from one form into multiple tables

    I'd like to use one form to insert data into several tables. I have gone through several screens and I don't have the ability to change the table. I'm not trying to create duplicate information. Just want one part of the form to insert to table x and another part of the form to insert to table y.

    Any thoughts?

    Many thanks

    Page

  2. #2
    Alpha Software Employee AaronBBrown's Avatar
    Real Name
    Aaron Brown
    Join Date
    Feb 2001
    Location
    Waltham, MA
    Posts
    2,836

    Default RE: Inserting data from one form into multiple tab

    Create a One-To-One set and base the form on that set. The will probably get you started.

  3. #3
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Inserting data from one form into multiple tab

    Page:
    use the following xbasic, it's rather very simple:
    Say you want the value in Field1 in your current form to be copied to FiledA in tableA and Field2 to be copied to FiledB in tableB
    t=table.open("TableA")
    t.Change_begin()
    t.fieldA=field!
    t.change_end()
    repeat the above for TableB
    You are done
    Gabe

  4. #4
    Page Sands
    Guest

    Default RE: Inserting data from one form into multiple tab

    Gabe,
    Do I add this code in the xbasic form editor?

    Many thanks
    Page

  5. #5
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Inserting data from one form into multiple tab

    Page:
    I am not sure what do you mean by the "Form editor", do you mean a form in design mode?
    You could attach this xbasic, say to a button on your form to the Onpush event. When you press that button, the script will execute.
    Gabe

  6. #6
    Page Sands
    Guest

    Default RE: Inserting data from one form into multiple tab

    ok, I will try that. Many thanks.

  7. #7
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default RE: Inserting data from one form into multiple tab

    Gabe,

    I think it's going to be a bit more complicated than that.

    field! is undefined. If this is supposed to be field1, then I think you have to either establish a pointer to the current table (to read the field value, as in tbl_ptr.field) or you have to get the "value" or "text" property from the field object displaying the field in the form (as in parentform:fieldobjectname.value).

    And, if you're changing a record in the external table, don't you have to navigate to it somehow?

    I wonder if Page is talking about "entering" a new record in the external tables?

    Maybe if she gives us a sample collection of tables we can whip something up for her. What she wants to do is not difficult as you correctly indicate. However, if she's a beginner she's going to need help deciding what "hook" to use in order to attach the script.

    -- t

  8. #8
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Inserting data from one form into multiple tab

    Tom:
    field! is a typo, I meant field1.
    Page indicates that she wants to, basically, update some fields in some external tables while she is in a form based on the current table.

    "..establish a pointer to the current table.." Good point: while she is in the current table there is no need for pointers, unless, if that field is not an object on the form.
    When you enter:
    t.fieldA=field1 fieldA from TableA will take the value of field1 if it is an object on form of the current table. If it is not an object on the form, then you are right, she will need either to add it to the form as an object or use a pointer as you indicated.

    I had assumed, I suppose safely so, that those fields are objects on the form, else how would you know what are you updating ?! But then again, who knows !

    table.open("") will establish the pointer to the external table.

    Actually I run simillar routines in my DB, it works flawlessly with that simple routine!!
    Gabe

  9. #9
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default RE: Inserting data from one form into multiple tab

    Gabe,

    Are you saying that if Field1 is the name of a field object on her form you can pass it's 'value' to the other table using

    t.fieldA = Field1

    ???

    If so, this is news to me, and I stand corrected. I thought it had to be

    t.fieldA = parentform:Field1.value


    -- t

  10. #10
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Inserting data from one form into multiple tab

    Yep. give it a try!
    In fact, it does not have to be an object on the form !! so long as you are in the current form (and thus in the current table) when you make a reference to a field name, alpha will accept that as a name of a field in the current table. In which case if Page is in a form and makes references to field values of that table, the external tables will be updated accordinglly !!
    To confirm my theory, I went and removed some objects from a form I have and the routine worked just fine !!
    Gabe

  11. #11
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default RE: Inserting data from one form into multiple tab

    Gabe,

    I cannot duplicate the handy technique you're describing.

    Would you be good enough to post a simple example?

    -- t

  12. #12
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default RE: Inserting data from one form into multiple tab

    Using a simple form, based on one table.
    The form contains a field object called IdNum, which displays the current value of a character field called IdNum in the form's table. Curr_id is a local variable in each script.

    This script works:
    curr_id = parentform:IdNum.text
    trace.writeln(curr_id)

    This one does not:
    curr_id = IdNum
    trace.writeln(curr_id)

    In the latter case Alpha reports that "Variable 'IdNum' can't be found". It doesn't recognize IdNum as a field in the table, or as an object name in the form.

    -- t

  13. #13
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Inserting data from one form into multiple tab

    Tom:
    Let's assume you named your table: "Test"
    Try this:
    curr_id = test-"IdNum

    That's all there is to it!
    Gabe

  14. #14
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,311

    Default RE: Inserting data from one form into multiple tab

    Thanks, I see what you're talking about now.

    So in the snippet for Page, it would be

    table_name-"field1

    right?

    -- t

  15. #15
    "Certified" Alphaholic G Gabriel's Avatar
    Real Name
    G. Gabriel
    Join Date
    Oct 2004
    Posts
    7,204

    Default RE: Inserting data from one form into multiple tab

    Right! Oversight on my part. My apology! Page, Please take note.
    Gabe

  16. #16
    Page Sands
    Guest

    Default RE: Inserting data from one form into multiple tab

    OK, thanks much. I will try this out.

Similar Threads

  1. Handling multiple tables With 1 Form
    By acant05 in forum Alpha Five Version 5
    Replies: 1
    Last Post: 07-04-2004, 09:19 AM
  2. Inserting a .bmp in a form
    By mel in forum Alpha Five Version 5
    Replies: 5
    Last Post: 11-09-2002, 06:11 PM
  3. multiple tables
    By BWilliams in forum Alpha Five Version 5
    Replies: 6
    Last Post: 10-16-2002, 07:03 AM
  4. need help to activate multiple tables on one form
    By crimmelcp in forum Alpha Five Version 4
    Replies: 2
    Last Post: 12-11-2000, 03:10 PM
  5. Lookups-Inserting data onto a form
    By Manish Bhalla in forum Alpha Five Version 4
    Replies: 2
    Last Post: 10-14-2000, 06:33 AM

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
  •