CFRONT

OK, I do not see a lot of c/front topics. I’d like to start a constructive exchange of ideas, so i’ll post the start of a VBA wrapper class. I have solved all preliminary problems in the wrapper (really: the included xls sample doesn’t work, took me hours, eventually the servertype appeared to be hardcoded to SQL, hmmm). Look at the code at the end. The idea is to hide all specific and “need to know” issues in a VBA wrapper class that we all can use. I use a Navision server configuration, but it is easy to modify. For beginners: start your local Navision server and (literally) use localhost as servername, this will allways refer to your own IP address. BUT I have a LOT of problems getting things to work beyond basic loging on and table access. First problem to solve: how do i retrieve the field array with the GetFieldDataArray method in VBA ? Tried a lot of variant constructions, but i cannot get it to work. If we have this, from there we can create a generic method to access a table by meta data. The test method in my class is called FindFirst and it should return a ADO record like structure… I tried to upload the file, but it failed. I can mail you the complete VBA project, no strings attached. Source comes at the end, please do your own Private Sub HandleError(intErr As Integer) as it takes a lot of space, or mail me for complete source… Import as a VBA class and (sorry, tabs disappear) Here goes: --------------------------------------------------------------- Option Explicit 'In multiple installations, point to last version 'example: 'Const STR_NAVDIR = “c:\navision\client360” 'This works most times: Const STR_NAVDIR = “” 'Yes, i think you really need to specify the company name, 'CASE sensitive mind… Const STR_NAVCMP = “CRONUS Nederland BV” Private objCF As CFRONT Private bolInitOK As Boolean Private Errors As Collection Public LastError As Integer Friend Function FindFirst(TableNo) As Variant 'Use record buffer Dim lngRec As Long Dim strBuffer As String Dim intFNum As Integer Dim iCounter As Long With objCF lngRec = .AllocRec(TableNo) intFNum = .FieldCount(TableNo) If .FindRec(TableNo, lngRec, “-”) Then For iCounter = 1 To intFNum strBuffer = strBuffer & .GetFieldData(TableNo, lngRec, iCounter) & vbCrLf Next Else strBuffer = “” End If End With FindFirst = strBuffer End Function Friend Function OpenTableByName(TableName As String) As Long Dim lngTableNo As Long LastError = -1 If bolInitOK = False Then Exit Function With objCF .OpenTable lngTableNo, .TableNo(TableName) OpenTableByName = lngTableNo LastError = .LastError End With If LastError <> 0 Then HandleError LastError End Function Sub OpenDatabase(ServerName As String, UserID As String, Password As String) If Not bolInitOK Then Exit Sub With objCF .ConnectServerAndOpenDatabase “NDBCN”, ServerName, “TCP”, “”, 1000, True, False, UserID, Password .OpenCompany STR_NAVCMP LastError = .LastError End With If LastError <> 0 Then HandleError LastError End Sub Private Sub Class_Initialize() Set objCF = New CFRONT Set Errors = New Collection With objCF .StopOnAllExceptions = False .SetNavisionPath STR_NAVDIR .HideError = True LastError = .LastError End With If LastError <> 0 Then bolInitOK = False HandleError LastError Else bolInitOK = True End If End Sub

Hi there. I’ve not much of a VB programmer so I can be of much help. I do have one question for you though. How is your wrapper going to differ from the C/Front OCX? Django