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!
|
|
Pull value from datagrid
Posted: 15 Jun 06 10:28 AM
|
fiogf49gjkf0d I'd like to pull one value from a datagrid and have that value populate another field in my form and I'm having a hard time pulling that one value. Specifically the value I'm looking to pull is STARTDATE from the ACTIVITY table. Any help/advice is appreciated. Thanks. |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 10:37 AM
|
fiogf49gjkf0d To get a value from a datagrid you can use the DataGrid.GetCurrentField function and pass in the fieldname (not the column's display name).
ie:
MsgBox "Start date value is: " & DataGrid1.GetCurrentField("startdate")
However, you could always just go to the database as well to get it if needed (if the grid is not in context with where you want this code to run) |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 10:42 AM
|
abortion pill mifepristone buy online buy abortion pill kit online website fiogf49gjkf0d Something I maybe should have mentioned in my original post: I want the date field to be populated at the time the new row is added to the grid, and updated if a new row is added as well. Would that still work? thanks. |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 11:50 AM
|
fiogf49gjkf0d Sure, but if you potentially have multiple rows in the grid, will you know which row you want the value from? The GetCurrentField function will get a value from the currently selected row in the grid. |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 12:06 PM
|
fiogf49gjkf0d Yes exactly. So I want the value to populate after I add the new row, and I want to check and make sure that I am pulling the most recent STARTDATE from all of the rows. |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 12:11 PM
|
fiogf49gjkf0d The only way to know you're pulling the most recent start date from the grid is to loop through all rows (or pull the recordset and filter it).
If it were me, I would just make a trip to the database to get the max(startdate) for the record you're on and not worry about the grid at all (except to know when to rerun the query) |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 2:32 PM
|
fiogf49gjkf0d The form is based off of another table though, not the activity table. Is there a place where I can look up the correct syntax for using a sql statement in my code to look up the value from another table? I have never been able to locate a good repository for that type of info. Thanks. |
|
|
|
Re: Pull value from datagrid
Posted: 15 Jun 06 2:56 PM
|
fiogf49gjkf0d A good place to look at the existing out of the box plugins to see how this is done in other areas. |
|
|
|
Re: Pull value from datagrid
Posted: 16 Jun 06 12:50 AM
|
fiogf49gjkf0d Your requirement will also be better served at the tab/grid level than at the Data Form/table/row level. What I mean is I have a basic lead customization that creates a mirror record linking the primary key to another key field. I used to do all of this processing at the Data Form level in the AXFormValidate event. I would post the record programmatically then add the mirror by copying the control structure before I let the form close. I moved the routine up to the grid level using the OnRowAdded and Edited events which made creating the copy a breeze since looping through the recordset is a little easier than the control structure. I would say use the grid level 99.9% of the time but there are cases where it's easier to do processing on the data form, like when columns aren't in the grid's recordset and you don't want to do any special procssing to pull them out. |
|
|
|