The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Finding the ID a data form will use when inserting data into a custom table before it saves.
Posted: 10 Jul 07 1:00 PM
|
I really didn't have a problem with this on a managed form being I could generate it's own ID, but this form has so many fields that I would hate to have to use SQL statements to insert and edit all the values.
I'm just trying to find the ID that my dataform will use when it inserts data to the custom table. The reason for this is I have embedded datagridds that obviously will not know where to bind it's data there for leaving unlinked records in the datagrids tables. Anyone run into this?
I've tried application.BasicFunctions.CurrentViewID with no luck as it seams to not know an ID at that current time. Only when I save and reopen the form does it display the currentviewid.
Frustrating....
Actually I just had an idea... Could I possible bypass the dataforms id that's generated with a basic GetIDFor("MYTABLE") and create a hidden field that inserts the table id?... |
|
|
| |
| |
|
Re: Finding the ID a data form will use when inserting data into a custom table before it saves.
Posted: 10 Jul 07 2:09 PM
|
Hehe. Nice little conversation you're having here
As you've found, you can stick a hidden label on a form, bind it to the ID field, then create your own ID and place it there. Then when the form saves it will use that as the ID for the data, instead of create a new ID value.
However, you'll want to use the form's OnChange method to create the new ID and place it in your hidden label instead of the OnShow. This will make it much more reliable as the Change fires whenever the form receives new data context for an add or edit. |
|
|
|
Re: Finding the ID a data form will use when inserting data into a custom table before it saves.
Posted: 10 Jul 07 2:20 PM
|
Thanks for the reply 
Wouldn't the OnChange cause the form to generate a new ID each time?
This is what I did to stop the field from generating a new ID each time and it's working great. Please let me know if I missed something 
Sub AXFormShow(Sender) If application.BasicFunctions.CurrentViewID = "" Then 'Basically if this is a new sale then generate an ID for the Sale, tracking, and repeat mailing tables saleid.Text = application.BasicFunctions.GetIDFor("PP_SALE") TrackingDG.BindID = saleid.Text MailingDG.BindID = saleid.Text Else 'Since the sale is already there, let the IDs populate from the table End If End Sub |
|
|
|
Re: Finding the ID a data form will use when inserting data into a custom table before it saves.
Posted: 11 Jul 07 8:48 AM
|
Absolutely NOT.
The ID is generated on the OK Validated Close (it isn't generated on a Cancel) of the form.
You can do something like
SUB AXFORMCHANGE(Sender) ' This is NOT on the Open, not on the Form Show, CAPICHE?! DIM TheFormID
IF application.basicfunctions.currenviewID = "" THEN TheFormID = Application.basicfunctions.getIDFOR("AardVark_Table") txtFormKeyID.TEXT = TheFormID ELSE TheFormID = txtFormKeyID.TEXT END IF
END SUB
|
|
|
|