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!
|
| |
| |
| |
|
Re: Dynamicaly created Grid on Sub form of account doesn't update when account detail changes.
Posted: 23 May 06 6:09 AM
|
fiogf49gjkf0d I have created a data grid in code dynamicaly on a form assosciated with the account screen( a tab). The Code works fine the first time and displays the desired data. However if I select a different account in the account detail screen, the data on my data grid doesn't update. I am able to initiate an event with a mouse click on the datagrid that causes it to update, but I can't find any other way to cause the form to refresh automaticly. I tried putting a reference into the account detail onchange event but that didn't work.
Code:
option explicit
Sub AXFormCreate(Sender)
Dim i If (Datagrid1.Columns.Count < 1) Then' > 0 For i = 0 To Datagrid1.Columns.Count - 1 Datagrid1.Columns.Item(0).Delete Next End If
Call LoadGrid
Call CreateGridColumns
End Sub
Sub GridReload(Sender) ' ********** Can't find an event to trigger this when the Account detail page refreshes Call LoadGrid End Sub
Function LoadGrid Dim objBASIC set objBASIC = Application.BASICFunctions Dim mySQL 'Build SQL statement and assign to the grid.sql property mySQL = "SELECT A1.ACCOUNTID, A2.PROD_NO, A3.PROD_DESC, sum(A2.QTY) as Quanity, Sum(A2.SALES_AMT) as Sales_TTL" & _ " FROM ACCOUNT A1" & _ " LEFT OUTER JOIN KSC_SALES_HIST A2 ON (A1.ACCOUNTID=A2.ACCOUNTID)" & _ " LEFT OUTER Join KSC_PROD_DESC A3 ON (A2.PROD_NO=A3.PROD_NO)" & _ " where A1.ACCOUNTID = '" & objBASIC.CurrentAccountID & "'" & _ " And SALE_DATE between (Getdate() - 365) and getdate()" & _ " Group By A1.ACCOUNTID, A2.PROD_NO, A3.PROD_DESC" & _ " Order by PROD_DESC"
'reassign the sql statement and refresh Datagrid1.SQL = mySQL Datagrid1.Refresh
End Function
Function CreateGridColumns 'loop through recordset field listing creating and defining properties of each column added. 'The sql statement must be assigned prior to calling this function as the columns 'field names are defined by referencing the grid recordset.fields listing. Dim y With Datagrid1 For y = 0 to 4 .Columns.Add(0) Select Case y Case 0 .Columns.Item(y).FieldName = "ACCOUNTID" .Columns.Item(y).Visible = False .Columns.Item(y).width = 10 Case 1 .Columns.Item(y).FieldName = "PROD_NO" .Columns.Item(y).Caption = "Prod Number" .Columns.Item(y).width = 20 Case 2 .Columns.Item(y).FieldName = "PROD_DESC" .Columns.Item(y).Caption = "Description" .Columns.Item(y).width = 50 Case 3 .Columns.Item(y).FieldName = "Quanity" .Columns.Item(y).Caption = .RecordSet.Fields(y).Name .Columns.Item(y).Width = 5 Case 4 .Columns.Item(y).FieldName = "Sales_TTL" .Columns.Item(y).Caption = "Sales Total" .Columns.Item(y).width = 10 '.Columns.Item(y).Format = "Currency" -- This doesn't work Says isn't valid
End Select Next End With End Function |
|
|
| |
| |
|
Re: Dynamicaly created Grid on Sub form of account doesn't update when account detail changes.
Posted: 24 May 06 8:37 AM
|
fiogf49gjkf0d Hello, a little trick that exist is one that you can use in this case, and it's to place the event in a EditBox of Field ACCOUNT.ACCOUNTID in the WhenChange event. In this way when you select a different account each time, you will be completely sure that this field going to change in the MainView of the Account. Maybe This can Help to you.
|
|
|
| |
|
Re: Dynamicaly created Grid on Sub form of account doesn't update when account detail changes.
Posted: 25 May 06 12:53 PM
|
naltrexone oral reviews naltrexone reviews for opiate addiction fiogf49gjkf0d You could set visible = false on the control you place as well. OnChange fires on an unbound form (it works for Managed Forms) but only if that form is NOT a tab. I think the reason this happens is that when the MainView is loaded, each tab is loaded and cached into memory (firing OnCreate just once). I believe the MainView is what determines if a tab needs an update. Literally every tab form I've ever made has been bound to something, as well as most stock SalesLogix code so it wouldn't surprise me that this is standard behavior. It wasn't until 6.2 that the opportunity screens went dynamic so I wouldn't have expected it to be different yet. v7 should be a different story, especially now that customers are pushing the boundaries of dynamic and inline grid editing. |
|
|
| |
|
Re: Dynamicaly created Grid on Sub form of account doesn't update when account detail changes.
Posted: 23 Aug 06 1:45 PM
|
fiogf49gjkf0d OK now it is refreshing, but leaving a ghost. So if: account 1 has dataA account 2 has none account 3 has dataB
Then when I scroll throught accounts my result set down on the tabspane shows "DataA, DataA, DataB" I am setting the variables = to nothing , but some how I need to force the Edit to blank. Thanks
-------------------------------------------------------------- sub TOTAL_2004 dim SQL_temp SQL_temp="SELECT sum(quantity) as qty , sum(Price) as Amount " &_ "FROM sysdba.c_Acct_Line_Orders " &_ " where OrderDate >'01/01/2004 00:00:00' and OrderDate < '01/01/2005 00:00:00' And " &_ " AccountID='"& Application.BasicFunctions.CurrentAccountID &"' " 'msgbox SQL_temp dim objClass dim objRS on error Resume Next Set objClass=New DataConnection objClass.Initialize Set objRS=objClass.ReturnRecordset(SQL_temp) If NOT IsEmpty(objRS) Then While NOT objRS.EOF BEdit11.text = objRS.Fields(0).Value BEdit12.text = objRS.Fields(1).Value objRS.MoveNext WEND objRS.Close Set objRS=Nothing Else err.Clear End If objClassTerminate Set objClass=Nothing End Sub |
|
|
| |
| |
| |
|