Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook



The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic

Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.

If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.

Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.

Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

a5 grid component - insert record to two linked tables

  • Filter
  • Time
  • Show
Clear All
new posts

  • a5 grid component - insert record to two linked tables

    SUMMARY: Access lets you join two tables into an updateable (and insertable) view without any code. That's right, Access will let you insert two linked records into two linked tables without any code. The A5 grid control doesn't do this, and it's buggy if you try to import the access view. Here's an incredibly simple database that unambiguously illustrates this issue. What's the best way to handle this?

    I have a database in MSAccess with two linked tables, linked by a left join. For discussion purposes, I call this the 'Men's club' database, and it has two tables : tblMen and tblWives. The database records the members and, if they are married, their wives. I use two linked tables, one for the members, and another for their wives. My real app is more complex, but I've simplified it in order to unambiguously encapsulate the joined table issue.

    Each member of the Men's Club has a record in tblMen (sorry ladies, I'm afraid they are all men), with fields:
    mID integer autoincrement
    mFirstname text
    mLastname text
    mWifeID integer ' external link to wife's record, if present

    tblWives has 3 fields:
    wID integer autoincrement
    wFirstname text
    wLastname text
    (again my apologies to domestic partners who don't fit this oversimplified model)

    I first created a view in MSAccess with a left join of tblMen and tblWives where tblMen.mWifeID = tblWives.wID. I immediately got a nice form where the member's name and his wife's name are all on one line. If I enter a member's name, but I do not enter a wife's name, then just a tblMen record is created. However, if I also enter his wife's name in the view's wFirstname and wLastname fields, then Access creates both a tblMen record for the man and a tblWives record for his wife, and stores the newly created Wives.wID in the man's mWifeID field. Access does this without any code. I'm not always a Microsoft fan, but this seems pretty intelligent on their part.

    If I try to do this in an Alpha 5 grid control defined by the same SQL left outer join, it doesn't work. Alpha 5 will not create the wife record, so it either gives an error or just ignores the wife data, depending on which grid template I try.

    If I do this with the Alpha 5 template for read-only grid with updateable detail, and base the grid's query on the joined MSAccess view, then A5 almost works. Basically, it inserts the data OK, but you have to close the grid and reopen it to see the data.

    (After I save the new record, the new record is not displayed in the Alpha 5 grid. Instead, a random previous record is repeated in the last row of the grid. Also, in this instance, the alpha 5 insert causes the access view to add a wife record every time, even if no wife data is entered. And, there is another problem if there is no wife data -- it gives an error message, but again, if you open and close the grid then you do get to see the data).

    Anyhow, my questions are these:
    (1) what's the best way to get the grid component to do this -- i.e., update two tables from one line in the grid? It looks like the grid based on a sql query can't do this without code. I realize that inserts into 2 tables are not supported in the most rigorous interpretation of SQL (there is an INSTEAD OF clause), but Access seems to be designed to let you do this without writing any code. More specifically, what's the easiest way to get the wives' record inserted in A5?

    (2) Is there any way to get the grid to correctly display after insert into an Access view? The view based grid seems to update the database OK, but you have to close the grid and repopen it to get it to display correctly. If this worked, I'd be able to import my codeless two table Access view into an A5 grid control and take the rest of the day off. This would be nice ;-)

    I've seen a few other posts on this topic, but never any clear resolution. This example is quite obvious and trivially replicable, and I'd be glad to upload the test tables and grid components I've based it on.


    Last edited by bruce2g; 10-29-2013, 01:32 AM. Reason: typos, added summary

  • #2
    Re: a5 grid component - insert record to two linked tables

    Could you provide a copy of your grid's SQL Select Statement (Query AlphaDAO)?
    Rapid Development, Training, Support


    • #3
      Re: a5 grid component - insert record to two linked tables

      I've tried it two ways. The first bases the A5 grid control on an Alpha DAO SQL Select statement:
      SELECT *
      FROM Men Men
      LEFT OUTER JOIN Wives Wives
      ON Men.mWifeID = Wives.wID

      mID is the primary key of table Men (autoincrement), and wID is the primary key of table wives.

      -- this does not work: if you add a record, and type in the man's name and his wife's name, only the man's name is saved, and no wife record is created.

      To get it to work, I instead created a view within Access, called linkMenWivesOnmWifeID_wID, and the access genie created the following SQL:
      SELECT Men.*, Wives.*
      FROM Men LEFT JOIN Wives ON Men.mWifeID = Wives.wID;

      This time, I used the A5 flying start genie to create my grid from scratch, and it did work (pretty much). Something about the flying start removed the record display problems. I notice that now, in detail view, on a new record, the wID field says <Auto> where before it was just an empty text box.

      The only problem remaining is that a wife record is always created, even if the wife's name is left blank. (I suppose I could create a SQL query to delete the blank wife records and null out the link, and run it when necessary for the time being).

      This really helps, though. I wish I could figure out how the wID got changed to <Auto> -- all the properties for the wID field look the same in both the version with <auto> in the wife table's ID and the version where it was just a text field.

      Last edited by bruce2g; 10-29-2013, 09:44 PM.


      • #4
        Re: a5 grid component - insert record to two linked tables


        this is the way alpha works, as i understands it. a table needs to be created then only the auto increment number is assigned and any relationship based on that will exist after that.
        i know you gave simplified version of your problem using men and wives.
        on the primary table you have an id field which references the secondary table auto increment field so whenever a record to the primary table is created automatically a blank record is added to the secondary table. in your case if you want to create a primary table and if there is any dependent record on that primary table then after saving the primary table you can create one or skip if there is none.
        to think in alpha terms, using your simplified example ( i am using mysql vocabulary)
        id integer auto increment primary key
        last_name varchar(20)
        first_name varchar(20)
        married tinyint
        primary table.

        id integer auto increment primary key
        last_name varchar(20)
        first_name varchar(20)
        primary_record_id int
        secondary table.

        note i have the foreign key in the secondary dependent table.
        now create a dialog(which i like ) or grid if you must. then after you save the record, the primary key of the last inserted record is available in the e object. use that to create the secondary record if the condition married is true, if not skip.
        whether you use dialog or grid the dependent part can be hidden unless the married is true.
        thanks for reading


        version 11 3381 - 4096
        mysql backend
        1 914 924 5171