Skip to main content

Can Virtual field removal cause IDEA crash

Hello all,
 
I wondered if anyone came accross any of the 2 situations below:
 
- situation 1:  IDEA crashes after performing all of the functions within the code - all of the tests are complete - the last line of code is displaying the message and then round circle is coming up on the screen and IDEA shuts down (just the database file - the code module remains open)
 
- situation 2: I have 2 versions of the same code. The only difference between the 2 version of the code is that the newest version has 2 cases of virtual field removal from the master database added (virtual fields are created earlier within the same procedure). In this case IDEA crashes very early on , while performing the function execution which does not have removal of virtual fields included.
Please let me know if you experienced simial issues with IDEA and what may be causing it.
 
 

Brian Element Wed, 02/05/2020 - 10:25

This can happen, especially in the case where the virtual field is used by another virtual field.  So in your case, if you have two virtual fields, VField1 and VField2, if vField2 uses VField1 and then you decided to delete both fields, if you delete VField1 first IDEA will probably crash because VField2 can't update properly, in that case you need to delete VField2 first and then VField1.

There are probably other scenarios.  This is a case where it is hard to tell without actually being able to test the code.  If your scenario is different you might want to contact your distributor to look at this as there could be something else going on.

bluecox Tue, 02/11/2020 - 05:33

Removing fields from the database in reverse order as they were created make sense but i might be experiencing a bit different issue here.
I created a simple generic function to append the field thoughout the programme:
 
 
Function Append_New_Field (TargetDb As Database, Req_Field_Type As Integer, Field_Name As String, Target_Equation As String)
 
Dim FieldName As String
Dim FieldEquation As String
Dim db As Object
Dim Mgt As Task
Dim ThisTable As Object
Dim FirstField As Object
 
FieldName = Field_Name
FieldEquation = Target_Equation
'MsgBox  FieldEquation  
 
' Open the sample database.
Set db = TargetDb 
' Create the task.
Set Mgt = db.TableManagement
' Obtain a reference to the table.
Set ThisTable = db.TableDef
' Create a new field.
Set FirstField = ThisTable.NewField
 
If  Req_Field_Type = 1 Then
    'Get the virtual Date field  
    FirstField.Name = FieldName
    FirstField.Type  = WI_VIRT_DATE
    FirstField.Equation =  FieldEquation
                    'FirstField.Length = 8                                    
    ElseIf     Req_Field_Type = 2 Then
                     'Get the virtual Character field
                     FirstField.Name = FieldName
                     FirstField.Type = WI_VIRT_CHAR
                     FirstField.Equation =  FieldEquation
                     FirstField.Length = 150
    ElseIf     Req_Field_Type = 3 Then
      'Get the virtual Numeric field
      FirstField.Name = FieldName
      FirstField.Type = WI_VIRT_NUM
      FirstField.Equation =  FieldEquation
      FirstField.Decimals = 0  
    ElseIf     Req_Field_Type = 4 Then
                      'Get the virtual Time field
                      FirstField.Name = FieldName
                      FirstField.Type = WI_VIRT_TIME
                      FirstField.Equation =  FieldEquation
                        
                  End If         
' Add the field.
Mgt.AppendField FirstField
Mgt.PerformTask
Set FirstField = Nothing                           
Set ThisTable = Nothing
Set Mgt = Nothing
Set db = Nothing
 
End Function 
 
I call the above function numerous times with the following structure(example):
Set TargetDb = MasterDb
Call Append_New_Field (TargetDb,2,"TRANSACTION_TAG", "@if(ROUND_COUNTER > -1,@str(ROUND_COUNTER,3,0), """" )")
 
The appending of field works correctly however the issue occurs when I remove the fields created earlier from the database with the below structure:
 
Set TargetDb = MasterDb
Set task = TargetDb.TableManagement
task.RemoveField "TRANSACTION_TAG"
task.PerformTask
Set task = Nothing
Set TargetDb = Nothing
 
I think removal causes the IDEA to crash but I cannot see any obvious problem in any of the code above (unless the append field function is somehow incorrect - but it works).
Just to clarify i remove the field in reverse order to which they were created (if one virtual field depends on another virual field).

Brian Element Tue, 02/11/2020 - 07:23

I see you are passing the database object instead of the name.  I have had some problems sometimes doing this.  Usually to be on the safe side I create the object within the function and then destroy it at the end of the function.  Can you try passing the database name to the function, then opending and closing it within the function, might not be the problem but I would be something I would test for.

The website encountered an unexpected error. Try again later.