itgensdf054 on synchronize in Invantive Control - excel

When synchronizing a model in Excel with one block, I receive an itgensdf054 error which indicates that it could not clear the target range where the data of the query below is synchronized into.
The full error message is:
Could not clear contents of the range ''Aangifte Bebat'!$A$6:$Q$129' of block 'ECO'.
Deze wijziging kan niet worden doorgevoerd voor de geselecteerde cellen omdat ze van invloed zijn op een draaitabel. Gebruik de lijst met velden om het rapport te wijzigen. Verplaats de draaitabel en probeer het opnieuw als u cellen wilt invoegen of verwijderen
Call stack:
Type: System.Runtime.InteropServices.COMException
bij System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
bij Microsoft.Office.Interop.Excel.Range.ClearContents()
bij Invantive.Producer.Control.SyncToDatabaseForm.SyncDownload(DoWorkEventArgs e) in File176:regel 1508
bij Invantive.Producer.Control.SyncToDatabaseForm.SyncDownload(DoWorkEventArgs e)
bij Invantive.Producer.Control.SyncToDatabaseForm.syncBackGroundWorker_DoWork(Object sender, DoWorkEventArgs e)
bij System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
The block 'ECO' synchronizes data from the following query on Exact Online:
select /*+ join_set(sik, invoiceid, 100) join_set(sil, invoiceid, 100) join_set(itm, id, 100) join_set(itr, id, 100) */sil.itemcode
, sil.description
, bom.batchquantity
, sil.quantity
, sil.netprice
, sil.amountdc
, sil.vatamountdc
, sil.vatcode
, sil.vatcodedescription
, sil.vatpercentage
, sik.invoicenumber
, sil.linenumber
, itr.itemgroupcode
, itm.class_04 --aanpassen naar inrichting klant = assortiment bebat_nomenclatuur
, itm.class_10 -- is assortiment 10 instellingen stuklijst explosie
, case
when sik.invoicenumber is not null
then '=if($C{D,.,.,.-5,.}=$C{D,.,.,.-5,.-1}, if($C{D,.,.,^+2,.}= "", $C{D,.,.,^,.-1}, $C{D,.,.,^,.}), $C{D,.,.,^,.})'
end
ass_itemcode
, case
when sik.invoicenumber is not null
/*=""&ALS(K6=K5;ALS(C6<>"";N6;N5);N6)*/
then '="" & if($C{D,.,.,.-6,.}=$C{D,.,.,.-6,.-1}, if($C{D,.,.,^+2,.} <> "", $C{D,.,.,.-3,.}, $C{D,.,.,.-3,.-1}), $C{D,.,.,.-3,.})'
end
nomenclatuur
from ExactOnlineREST..SalesInvoiceLines sil
join ExactOnlineREST..SalesInvoices sik
on sil.invoiceid = sik.invoiceid
join ExactOnlineREST..Items itm
on sil.item = itm.id
join ExactOnlineREST..ItemsRead itr
on sil.item = itr.id
left
outer
join ExactOnlineXML..BillOfMaterials bom
on sil.itemcode = bom.item_code_attr
order
by sik.invoicenumber
, sil.linenumber
The query or the model has not changed when it worked before.
There is a pivot table in the Excel sheet which summarizes the list of sales details.
What is causing this error?

From your comments I understand that the pivot table is in 'Aangifte Bebat' worksheet, but the downloaded is in 'Details' worksheet.
I think you have made a slight alteration. Probably you have inserted or moved a new worksheet BEFORE the Details worksheet. Since Invantive Control downloads based upon the number of the worksheet, the data has now been moved.
Make sure that the original order of worksheets is restored.

Related

Merge multiple cells into one merged cell with line spacing

I was working on an excel template to make quotes. This template has a list of materials which you can validate so that a quote is automatically generated.
In itself, the template works fine, the problem appears when I try to add a new function, which will allow you through "UserForm" to insert a new item to the list.
Before this function, I was using the "=CONCATENATE" command to drag several items from the list to the final quote and added a "CHARACTER(10)" so that there is a line spacing between each item because it must appear in unified cells so that then the command "=SHEARCHV" returns all the items. When trying to automate this process, I realize that when I add a new row to the list, it is not added to the list of "=CONCATENATE" so, even though it works in the total sum, the specific item never appears in the description of the items in the final quote.
here some captures
First Step: Check whatever item you want to add
Second Step: The item will move to another sheet to add taxes and prorate as well as labor
Third Step: After that I should send the items that are separated in a single cell and with a space between each one so that finally the function "=SHEARCHV" looks for the "Server Room" and returns me the description of the items like the next image
In the yellow format you can see how the template worked before adding this new function
What I want to do is that when adding a new item to the list I also add a function which can insert several cells in a combined multiple cells, so that there is a line spacing between each item
Main lenguaje: Spanish
Excel Download: https://drive.google.com/file/d/1xUxd7Ze6AB25MVfyxlY9dSlWUeQBTDCH/view?usp=sharing
VBA CODE TO ENTER NEW ITEM
Sheets("PREVISTA").Range("A25").EntireRow.Insert
Sheets("PRORRATEO").Range("A48").EntireRow.Insert
Sheets("HOJA DE DATOS").Range("A22").EntireRow.Insert
Sheets("HOJA DE DATOS").Range("A22") = 1
Sheets("HOJA DE DATOS").Range("C22") = 1
Sheets("HOJA DE DATOS").Range("B22") = TextBox1
Sheets("HOJA DE DATOS").Range("G22") = TextBox2
Sheets("HOJA DE DATOS").Range("E22") = "=G22*'DATOS DE INTERNET'!C2"
Sheets("HOJA DE DATOS").Range("H22") = "=G22*C22"
Sheets("HOJA DE DATOS").Range("I22") = "=G22*$I$2"
Sheets("HOJA DE DATOS").Range("J22") = "=G22*$J$2"
Sheets("HOJA DE DATOS").Range("K22") = "=G22*$K$2"
Sheets("HOJA DE DATOS").Range("L22") = "=(K22+J22+I22)*$L$2"
Sheets("HOJA DE DATOS").Range("M22") = "=(I22+J22+K22+L22)*C22"
Sheets("HOJA DE DATOS").Range("N22") = "=H22+M22"
Sheets("PRORRATEO").Range("C47").Copy: Sheets("PRORRATEO").Range("C48").PasteSpecial xlPasteAll
Sheets("PRORRATEO").Range("V47").Copy: Sheets("PRORRATEO").Range("V48").PasteSpecial xlPasteAll
Sheets("PRORRATEO").Range("X47").Copy: Sheets("PRORRATEO").Range("X48").PasteSpecial xlPasteAll
Sheets("PRORRATEO").Range("F48") = "=C48/$C$2"
Sheets("PRORRATEO").Range("G48") = "=F48*$D$17"
Sheets("PRORRATEO").Range("I48") = "=G48/($C$20+$C$3)"
Sheets("PRORRATEO").Range("J48") = "=I48*$F$9"
Sheets("PRORRATEO").Range("K48") = "=J48+G48"
Sheets("PRORRATEO").Range("O48") = "=N48+M48+L48+K48"
Sheets("PRORRATEO").Range("B48") = "=CONCATENAR(X48)"
If CheckBox1.Value = True Then
Sheets("PRORRATEO").Range("L48") = "=K48*L24"
ElseIf CheckBox2.Value = True Then
Sheets("PRORRATEO").Range("M48") = "=K48*M24"
ElseIf CheckBox3.Value = True Then
Sheets("PRORRATEO").Range("N48") = "=K48*N24"
Else
Sheets("PRORRATEO").Range("N48") = "=K48*N24"
End If
Sheets("PRORRATEO").Range("Q48") = "=O48/O5"
Sheets("PRORRATEO").Range("R48") = "=Q48*O6"
Sheets("PREVISTA").Range("C24").Copy: Sheets("PREVISTA").Range("C25").PasteSpecial xlPasteAll
Sheets("PREVISTA").Range("N24").Copy: Sheets("PREVISTA").Range("N25").PasteSpecial xlPasteAll
Sheets("PREVISTA").Range("P24").Copy: Sheets("PREVISTA").Range("P25").PasteSpecial xlPasteAll
Sheets("PREVISTA").Range("B12") = "=CONCATENAR(P12:P26)"
End If
End Sub ```
I hope I have expressed myself well, any help is welcome thanks

How can I turn on Data/Filter mode on Excel sheets from MATLABvia ActiveX?

My MATLAB code produces data that I want to send to Excel. I use ActiveX Server in MATLAB to both produce the Excel file and to do the export (I can control more properties of the resulting Excel file this way than by using the 'writetable' command). In the produced Excel file, I manually have to chose the menu 'Data/Filter' to turn on the function letting me filter and sort each column (visible as the small triangles in the column headings as shown in the illustration below).
How can I turn on this function with ActiveX from MATLAB?
Call the AutoFilter method on an Excel Range object. For example, if you have a worksheet object MySheet:
rangeToFilter = get(MySheet,'Range','A1:B3');
rangeToFilter.AutoFilter
You can use a simple function that helps you to get the range depending on the size of the data that you will send to excel. For example:
idx2=size(data,2);
rangeToFilt=join(["A1:",idxtoexcel(idx2),"1"],"");
rangeToFilt.AutoFilter
function rexcel=idxtoexcel(idx)
% Función que permite obtener el número y letra de las filas y columnas que ocupará una matriz a imprimirse en un libro de excel.
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if idx < 27
rexcel = alphabet(idx);
else
idx2 = rem(idx,26);
if idx2 == 0
rexcel = [alphabet(floor(idx/26)-1),'Z'];
else
rexcel = [alphabet(floor(idx/26)),alphabet(idx2)];
end
end

Exporting Access Database with Errors

i have access to an MS Access database connected with oracle (I just have permissions to view and copy information, not to edit):
And I Found some rows with value '#Error':
When I click on an error row, this warning is displayed:
I want to export this database but this warning appears again and exportation process fail.
I build a macro that can export the db but it isn't exporting ALL the data:
The result of the export is an excel file with 65534 rows and my db has 72437 rows! the are 6903 rows with value information which my macro doesn't pull into the excel file.
And I have a macro I used to pull the data from access and before this #Error rows appears, it had been working successfully:
Public Sub Bajada_OIT()
Sheets("OIT").Select
'variable para almacenar la conexion
Dim conexion As Object
'variable para almacenar los datos de la consulta al fichero access
Dim recordSet As Object
'variable con la consulta SQL
Dim consulta As String
'viarable donde almacenamos la cadena de conexión
Dim cadenaConexion As String
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'instanciamos el objeto conexion
Set conexion = CreateObject("ADODB.Connection")
'elegimos el proveedor que vamos a usar y donde se encuentra nuestra base de datos
cadenaConexion = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\SEC\COST\COST\DIT\DIT.accdb"
'consulta que haremos a la base de datos
consulta = "SELECT * FROM ADAS_PCO_OIT;"
'abrimos la conexión
conexion.Open cadenaConexion
'ejecutamos la consulta y nos traemos los resultados (recordset)
Set recordSet = conexion.Execute(consulta)
On Error Resume Next
Sheets("OIT").Range("A2").CopyFromRecordset recordSet
'Este error es debido a que la base de datos tiene filas con valores #Error que no pueden ser copiados al portapapeles.
If Err.Number = -2147467259 Then
MsgBox "La base de datos contiene datos imposibles de copiar, se ha cancelado la extracción automática."
Remove_Bajada_OIT
Exit Sub
End If
On Error GoTo 0
'cerramos el recordset
recordSet.Close
Set recordSet = Nothing
'cerramos conexion
conexion.Close
Set conexion = Nothing
MsgBox "Extraccion de Acces: ADAS_PCO_OIT (OIT) Satisfactoria.", vbInformation, "Ayuda"
End Sub
What would be the appropriate SQL query so that the errors are not displayed and the macro works again?
Or what configuration would I have to do in the database so that these errors do not appear (remember that I am not the administrator of this database)?
I Could resolve this problem doing the connection again in a new Access file:
Creating a new Access Blank desktop database.
On the External Data ribbon, choose the option "ODBC Database" That is in Import & Link Section.
Choose the source and destination area (you can specify how and where you want to store the data in the current database).
Create a New DSN File Data Source.
Select the driver for which you want to set up a data source (In my case, i use the "Oracle in OraClient12Home 1_32bit" 12.01.00.02 Driver Version)
Type the name of the file data source you want to save this connection.
Finish (Next you need to have accession privileges for enter the database if it has user/pw security).
It seems that my Data base connection had corrupted and doing this steps again has solved my problem.
I Hope this solution may solves this problem if anyone has the same trouble.

Dropdown list with Adodb query

I would like to create the dropdown list with the results from my query. I'm looking for help please because I don't know how to display this results on the list.
The exemple of the list:
My query is :
'DROPDOWN LIST
Private Sub cb_gest_Change()
If Not FSD.cb_gest.MatchFound And FSD.cb_gest <> "" Then
MsgBox "Saisie impossible, le gestionnaire n'existe pas !", , "Contrôle
Gestionnaire"
FSD.cb_gest = ""
Else
FSD.Cells(29, COL_DATA) = FSD.cb_gest
End If
End Sub
'DROPDOWN LIST
Sub init_combo()
Dim Resultat As ADODB.Recordset
Dim Requete As String
FSD.cb_gest.Clear
Requete = "select lb_gestion from DB_GESTIONNAIRE "
Requete = Requete + "WHERE (d_deb_valid <= TRUNC(SYSDATE) OR d_deb_valid IS
NULL) AND (d_fin_valid >= TRUNC(SYSDATE) OR d_fin_valid IS NULL)"
Requete = Requete + " ORDER BY LB_GESTION"
Set Resultat = New ADODB.Recordset
Resultat.ActiveConnection = oBase
Resultat.Source = Requete
Resultat.Open
While Not Resultat.EOF
FSD.cb_gest.AddItem Resultat!lb_gestion
Resultat.MoveNext
Wend
If FSD.Cells(29, COL_DATA).Value <> "" Then
FSD.cb_gest = FSD.Cells(29, COL_DATA).Value
Else
FSD.Cells(29, COL_DATA).Value = ""
End If
End Sub
Thank you for your help !
Consider a different, codeless approach:
Add a new sheet to the host document / workbook
Import the external data from the "Data" Ribbon tab (select "From SQL Server")
Excel creates a ListObject table backed with a QueryTable object that uses a WorkbookConnection that can be configured to automatically refresh on open, or left alone as a one-time pull.
Select the produit column in the ListObject/table; Excel highlights the entire column content and leaves the heading un-selected.
From the "Formulas" Ribbon tab, click the "Define Name" command in the "Defined Names" group.
Name the range ProductsList, verify it refers to TableName[produit] so that it automatically grows and shrinks to fit the column contents.
Change the data validation list to =ProductsList.
Hide the worksheet housing the query and table, if needed.
No code needed, and the validation list will always keep up with the query results as they are refreshed.
Side note, the query appears to be making inefficient cross-joins, and at least one of them is a where-join that can be expressed as an inner join. Are you sure the query is yielding the expected records (I'm suspecting it's yielding a ton of duplicates, depending on how many records exist in the cross-joined tables)?
SELECT prod.cd_produit AS produit
FROM db_dossier sousc, db_produit prod, db_protocole proto, db_tiers tiers, db_personne pers
WHERE sousc.cd_dossier = 'SOUSC' AND sousc.lp_etat_doss NOT IN ('ANNUL','A30','IMPAY') AND sousc.is_produit = prod.is_produit
Instinct would be to remove the tables we're not selecting or filtering anything from - if this query produces the same expected output, then assuming primary and foreign keys are defined I believe its execution plan would be more efficient:
SELECT prod.cd_produit AS produit
FROM db_dossier AS sousc
INNER JOIN db_produit AS prod ON sousc.is_produit = prod.is_produit
WHERE sousc.cd_dossier = 'SOUSC' AND sousc.lp_etat_doss NOT IN ('ANNUL','A30','IMPAY')

Finding a tab name using string

The problem is that I don't know the exact code to find a tab using a variable.
For now my macro create a new tab in another workbook using the Range D26 as the name of my active workbook and is able to copy my form in the other workbooks but not in the right sheets. In fact it just send me to the debug.
Dim Titre As String
Titre = Range("D26").Value
Workbooks.Open "C:\Users\charl\Desktop\Programe comptable projet\Menu automatisé Test\Feuille de projet.xlsx"
Workbooks("Feuille de projet.xlsx").Worksheets(Titre).Range("B2") = Workbooks("Menu Automatisé.xlsm").Sheets("Fiche de création de projet").Range("D8").Value
I expect the program to copy of my form in the other workbooks in the tab I just created using the button. (The tab is created first)
Never mind I just found why it's not working. I was not precise enough for my string variable.
Dim Titre As String
Titre = Workbooks("Menu Automatisé.xlsm").Sheets("Fiche de création de projet").Range("D26").Value

Resources