Hi :5) , the following problem : Tried to use cfront.ocx from within navision financials : everything went ok except for the ASSIGNFIELD method which requires {hTable,hRec,FieldNo,FieldData)
The problem is with the last VAR : its type is VAR VARIANT. In NF Help it is said that NF converts from/to variant any of the types used. But this is VAR VARIANT : [ maybe defined as VARIANT* ]. I've tried aeverything : simulating the variant structure within a text,char array,binary . but no success in setting this variable. The error returned from the OCX : One or more of the parameters could not be coerced.
Please help ... 10x.
0
Comments
It's the same if you try to read decimals from another navision database through the cfront ocx. They are also returned as variants, and variant data type is not supported.
Head of Project & Analysis, Navision Competence Center
Columbus IT Partner
Also, could I have some sample code from your tests?
the Navision Excel example on the CD's has a VB Module which uses the calls you have just metion and it works fine!
I have done some trial work with 1.10 and Access, I will have a look for the functions and post what I have!
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk
FieldNo and fieldDate are Arrays
I have found some code from 1996 that worked at the time!
It read from an Access Database into a Table in Navision
I still have a Version of the database with the Module, if you want it I will mail it to you!
It copies the value from an access Sales Header and Sales Line, to a Table within Navision!
Some of the Variables are Declared at a Higher Level
Public Sub ExportRecord(Item As Boolean)
Dim ExportT As Long
Dim ExportR As Long
Dim FList As Variant
Dim FType As Variant
Dim FQty As Variant
ExportT = OpenTableByName("Import Order")
CF.BWT
Call CF.locktable(ExportT, True)
ExportR = NewRecord(ExportT)
'Enter Code To Check to See if Already Imported
Call CF.FreeRec(ExportR)
ExportR = NewRecord(ExportT)
'Returns 18 Navision Field Numbers from the Field Names FList = FieldNoList(ExportT, Array ("OrderID", "Type", "Cust/ItemID", "Field 3", _
"Field 4", "Field 5", "Field 6", "Field 7", "Field 8", _
"Field 9", "Field 10", "Field 11", "Field 12", "Field 13", _
"Field 14", "Quantity"))
If Item Then
Dim FItem(0 To 5) As Variant
Dim x As Integer
FItem(0) = Forms![Orders]![Order Details Subform]![OrderID]
FItem(1) = "Sales Line"
FItem(2) = Forms![Orders]![Order Details Subform]![ProductID].Column(0)
FItem(3) = ""
FQty = Format(Forms![Orders]![Order Details Subform]![Quantity], "##,##0.00")
FItem(4) = Format(Forms![Orders]![Order Details Subform]![Discount], "##,##0.00")
FItem(5) = Format(Forms![Orders]![Order Details Subform]![SalePrice], "##,##0.00")
For x = 0 To 5
Call CF.AssignField(ExportT, ExportR, FList(x), FItem(x))
Next x
Call CF.AssignField(ExportT, ExportR, FList(15), FQty)
Else
Dim Fvalue(0 To 14) As Variant
Dim i As Integer
Fvalue(0) = Forms![Orders]![Order No]
Fvalue(1) = "Sales Header"
Fvalue(2) = Forms![Orders]![CustomerID].Column(0)
Fvalue(3) = Forms![Orders]![Name]
Fvalue(4) = Forms![Orders]![Name2]
Fvalue(5) = Forms![Orders]![Address]
Fvalue(6) = Forms![Orders]![Address2]
Fvalue(7) = Forms![Orders]![County]
Fvalue(8) = Forms![Orders]![City]
Fvalue(9) = Forms![Orders]![PostCode]
Fvalue(10) = Forms![Orders]![Country]
Fvalue(11) = Format$(Forms![Orders]![OrderDate], "Short Date")
Fvalue(12) = Format$(Forms![Orders]![Required-byDate], "Short date")
Fvalue(13) = Forms![Orders]![Contact]
Fvalue(14) = Forms![Orders]![Reference]
For i = 0 To 14
Call CF.AssignField(ExportT, ExportR, FList(i), Fvalue(i))
Next i
End If
Call CF.InsertRec(ExportT, ExportR)
CF.EWT
Call CF.FreeRec(ExportR)
Call CF.CloseTable(ExportT)
End Sub
Hope this is of some use!
MindSource (UK) Limited
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk
Not Reading to posts properly!
If I remember correctly, I did create a Dialer OCX, I had to create a wrapper and had the same problem!
If you create an OCX you have to pass From Navision to the OCX Not as Variant but "By Val"!
MindSource (UK) Limited
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk
In Access you can define any Navision Table as "Linked ODBC Table" and write/read to/from this table like it would be an Access-Table.
So probably there is a better solution than CFRONT in your case.
It might be helpful if you describe the task you attempt to perfom.
Marcus
Marcus Fabian
m.fabian@thenet.ch
+41 79 439 78 72
Marcus Fabian
But, as I understanding Borislav trying use CF from NF env. the problem is that Variant data type is only one way compatible !!
VB->NF is OK, NF->VB is not compatible.
If you will use wrapper you must create func. for everyone datatype.
The Array of fields you can traslate like string:
'12,15,20' and in vb create array of int.
Keep in mind that cf makes new connection to dbm and new handles, you can't pass rec handles to cf.
My C/Front work was all Driven from VB.
That was before Automation (Version 1.10)
When the ODBC was One Way!.
Borislav must be updating a secondary Navision Database from Within Navision.
Maybe a Transaction Database?.
There seems Like a couple of workarounds
He could then passout the values to an OCX which will Update the Secondary Database.
He could upgrade to the SQL Version and use Linked tables through his Navision ODBC source.
MindSource (UK) Limited
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk
[This message has been edited by Dave Cox (edited 18-07-2000).]
Navision Service Partner
david@mindsource.co.uk
info@mindsource.co.uk