Using VB and CFRONT to insert a record

I’m trying to accomplish the simple task of opening a table and insterting a new record from VB using CFRONT. It breaks on the first AssignField line and gives me a type mismatch error. In Navision table 50001, field 1 is Integer and field 2 is Text. Why isn’t this working? Here is my code so far. Dim objCFRONT As CFRONT Dim lHtbl As Long Dim lHrec As Long Set objCFRONT = New CFRONT With objCFRONT .OpenDatabase “C:\Program Files\Navision Financials\260\database.fdb”, 8000, 1 .OpenCompany “CRONUS USA, Inc.” .OpenTable lHtbl, 50001 lHrec = .AllocRec(lHtbl) .BWT .InitRec lHtbl, lHrec .AssignField lHtbl, lHrec, 1, 100 .AssignField lHtbl, lHrec, 2, “data1” .InsertRec lHtbl, lHrec .EWT .FreeRec lHrec .CloseCompany .CloseDatabase End With Set objCFRONT = Nothing Also, besides the CFRONT.xls file and this message board, does anyone know where I could find out more information on using CFRONT with VB? The PDF file looks like all C. Phil Derksen

Order of func calls is OK. I don’t know VB (I’m using C) grammar and can’t say it’s Ok or NOT. Tray to check returning values of func,maybe one of them failing before Assign field. for more info check CFfront.hlp file.

When you use the OCX the following file will work: Dim lHtbl As Long Dim lHrec As Long Dim ValueField1 As Variant Dim ValueField2 As Variant ValueField1 = 100 ValueField2 = “data1” 'CFRONT1 is an ActiveXcontrol from CFRONT.OCX With CFRONT1 .OpenDatabase "C:\Program Files …[etc] .OpenCompany “CRONUS USA,Inc.” .OpenTable lHtbl, 50001 lHrec = .AllocRec(lHtbl) .BWT .InitRec lHtbl, lHrec .AssignField lHtbl, lHrec, 1, ValueField1 .AssignField lHtbl, lHrec, 2, ValueField2 .InsertRec lHtbl, lHrec .EWT .FreeRec lHrec 'Don’t forget to close the table! .CloseTable lHtbl .CloseCompany .CloseDatabase End With As you can see, you should send variants. with regards, Anolis - Netherlands Edited by - anolis on 10/5/00 10:48:46 AM

That did the trick! You always have to use Variant variables when using Assign Field like you did. I had even tried using the VB convert to variant function (i.e. CVar(100)) and it did not work. Thanks for the help. Phil Derksen

There is one (maybe big) problem comming up. The use of variants will be historie soon. Last week I visited the Microsoft Developer Days. They introduced Visual Studio.Net(7.0). There are realy a lot of changes. One of them is the strict way of using variables. Variants will no longer excist. This will be a problem when you want to use VB and C/Front. So, is there anybody out there that knows an other way to fill fields, without using variants?? Martin Pennings Sittard Netherlands

You don’t need to be change to VS(VB) 7.0 immediately. VB6 will do for quite some time to come. And when thinking of changes… rumours go that the development environment in the upcoming Navision 3.0 will be VBA (Visual Basic for Applications). Anybody who knows more about this? John

The development environment for Navision might be VBA? Personally, I would love that! Of course I’ve been developing in VB for several years, and in Navision just a short time. That would definitely help a lot of the issues of using Navision as an automation server (and automation controller) that I’ve come across. I also went to the recent MS Dev Days and have seen VB.NET demonstrated several times. From what I’ve heard though Visual Studio .NET won’t be released until at least mid next year, although next month they should release the first beta. Is there a planned release date for Navision 3.0? Phil Derksen

VBA for Navi!!! It would be a great step for editing code… …when will this feature be include? (navi 100.0b ?) Bye

VBA in Navision…will my dream come true? How about C++ for Navision? No serious, does anybody know anything about the integration of Navision in the .Net environment? Martin Pennings Sittard Netherlands

I don’t know what Navision’s plans are, but many companies are already preparing to integrate with Visual Studio.NET (check out If the next version of Navision won’t be released until around the time Visual Studio.NET will be released, they might as well skip integrating with VBA and go straight to .NET. This way any language (not just VB) could be used to develop in, since in .NET and ASP.NET your programming language preference doesn’t matter. Hundreds of programming languages are going to be available to use in .NET. Heck, even C/SIDE could be used (or at least Pascal). Phil Derksen

Some impressions of the upcoming version were presented at the annual meeting at Navision A/S (see Not clear though what will change in the development environment. However, earlier this year it was rumoured that a whole bunch of Microsoft developers (some 40 - 50 (wo)men was mentioned) was working hard at the Navision Denmark offices to assist in development of the new version, while at the same time some 20 people from Navision were at Microsoft in Redmond. That points in the direction that there’s more involved than just a few updates of code here and there. Anybody around that can give more insight? John

John, The mayor enhancements planned for version 3.0 are - as far as I know - XML as well as converting Navision forms runtime to ActiveX controls and therefore make it possible to have Navision Forms on the Web without doing too much editing. About VB (= Visual Basic; where BASIC = Beginners All purpose Symbolic Instruction Code) I think the day this crap language enters the Navision world I will leave Navision! Marcus Marcus Fabian phone: +41 79 4397872

What ever you say. VB is not as simple as it sounds…but it’s a good excuse not to get in trouble when you don’t know how to use VB. One thing is for sure: if there is a language that can be called “crap”, it is C/AL. Grow up, an try VB, just to see what you can do with it! Martin Pennings Sittard Netherlands

To Phil Derksen: First of all did you have any luck finding out any more info on using cfront with VB? Secondly, how did you add the cfront object to your VB project? I am very interested in any development using VB tool accessing Navision database.

I always thought that BASIC stands for: Basic And Simpletons Incomprehensible Crap. But in saying that: What ever Navision chooses to use, it must come with a better development environment with the current one that we are using today. Regards Graham. P.S I hope its VB.NET now that it got Inheritance. P.P.S I beer to VB.NET

To CMDunbar: I haven’t gone much further using CFront in VB except for inserting data into a field and then closing out. And this was just a test to see if it could be done. The code that I used is the first post of this message topic except where Anolis corrected me (third post) in that I had to assign values to variant variables and then use those variables in the AssignField method. I’m sure there are lots of quirks in using CFront and VB, and like I said I couldn’t find any documentation except for the C code in the CFront PDF file. Setting a reference to CFront was also strange. In your VB Project References, it doesn’t show up on the list. You must click Browse and select the CFront.OCX. CFront.DLL is not created as a COM object for us VB prorammers, but the OCX can be used like a DLL. To the rest of the group: We shouldn’t get into too big a fuss about what programming language is best here. I consider myself a VB guru, but some of you might also prefer C++, C/SIDE, or some other language as your tool of choice. That’s the beauty of Microsoft .NET framework. Hundreds of languages can be used to develop in, many I’ve never even heard of. VB particularly is getting an overhaul to add more object-oriented features like true inheritance and polymorphism. C# (C sharp) is supposed to allow C/Java programmers to write applications as fast as VB. Microsoft said that performance and capabilities between VB and C# will be practically the same. If you want to see a good discussion on this check out the last two MSDN shows at Although I have not heard much about any major changes to Navision’s development environment, I have heard that they will be incorporating Biztalk and more XML features. I think this is a great move since I see Biztalk as a key part of the future of B2B transactions. I already see many instances in my company’s current projects where Biztalk would be a perfect solution if it was more established. Anyone else have thoughts on Biztalk as related to Navision? Phil Edited by - pderksen on 10/25/00 7:51:42 PM

Fabian, Not to offend you, but obviously your perception of programming in BASIC is a bit outdated. Ten years ago, you might have been right. But Visual Basic as available now is a mature development platform, with close as many capablities as i.e. C++ - for those who know how to use it. It’s likely to be the most widely used RAD (Rapid Application Development) tool. Look for example at what capabilities you have with Macro programming in MS Office - and that’s VBA (Visual Basic for Applications), a subset of VB. I don’t want to start a yes/no discussion on programming languages here. Each is having its strengths and weaknesses, some technical, others are a matter of personal flavor, taste and preferences. Over the years, I have been working in too many languages to condemn one that’s not my favorite. John PS: Start a new thread on NF 3.0 issues? This one is becoming a bit fuzzy now.

Martin, >>VB is not as simple as it sounds…but it’s a good excuse not to get in trouble when you don’t know how to use VB.<< Like everybody who starts programming, I started with BASIC. That was 20 years ago. In the meantime Basic and Visual Basic crossed my way many times. I’m not a VB professional but I guess I’m quite up-to-date until VB 5.0. However, in my long life as software engineer I had opportunity to develop in many other programming languages such as Assembler, Cobol, Pascal, Modula, Delphi, C, C++, Ada, Lisp, Prolog and Java. So, yes: You might consider me as “grown up”. Having seen so many developement environments might put me into the position to judge about which one is suiteable for a given problem and which one is not. VB is IMHO a good programming language to start with. In fact, most people start with VB. But if they are growing older and more experienced they switch to C++, Delphi or Java which have certain advantages over VB. I don’t see VB as environment for Navision for the following reasons: 1) VB code is extremely slow compared with the others. 2) VB is a pure Microsoft product and runs only on Windows 3) VB produces a hell lot of machine-code: Compare the size of an EXE-File for a Hello-World program made in VB, C and Delphi. 4) VB needs a lot of external libraries to be installed. Creating a simple EXE-File is out of question. 5) The installation and upgrade-policy for VB is (to be nice) lousy! If you have VB-Programs on your system which were made with different VB-Versions you can run deeply into trouble as the VBRUNxxx.DLL’s are everything but compatible. In fact, I even had the case that a VB-Program didn’t run anymore after Installation of Office 97. Obviously Office had installed a new version of the Jet-Engine. As far as C/SIDE is concerned. Well you are right. It’s not the best and most sophisticated developement environment I could imagine. In a way it’s already about 17 years old as C/SIDE is nothing else than a modified version of Turbo-Pascal 3.0 which Navision had purchased from Borland. If I would have to choose a new developement environment I would decide between C++, Delphi and Java. C++ is a little bit difficult to read, Java is still too slow. Delphi has the advantage of being close to the syntax of C/SIDE as both have their origin in Turbo Pascal. So this would be my personal choice. But this is very subjective as I don’t know VB.NET yet. Marcus Marcus Fabian phone: +41 79 4397872

Marcus, Alright I agree on you about VB5.0 One of the nice thing about the .NET environment however is that the “DLL-Hell” is over. The same for the “runtimes” And yes, VB produces a lot of overload, which might make it not the best language to use with Navision. Myself I would like to see c# integrated in Navision, but this will be impossible since that would mean that Navision should be Object Oriented. I know Navision Denmark likes to say C/AL is Object Oriented, but lets be fair: it’s not. Just think of the consequences when something like this would happen. The IDE would be completaly different, and probably one of the most important things: We (developers) will be able to make Navision-based applications that have nothing to do with the “Navision concept”. Maybe we should come up with an conclusion, and send it to Navision Denmark? Martin Pennings Sittard Netherlands

My conclusion: programming language is not the main problem… the problem is the editor-debugger (Turbo Pascal 5 editor was better). A more advance development enviroment (like VB or VC++ or DELPHI) would be a great step! bye