Solved

find first problems

Posted on 1998-12-19
6
187 Views
Last Modified: 2008-02-20

   recursion. before each iteration i check at the beggining of the recursion if the specific node
   was not already inserted to the table because in this tree a certain node might be located
   under several nodes in diffrent levels of the tree. on the second entry to the recurion after
   inserting one record to the table, the debuger stops at this line saying there is a syntax
   error(an operator missing):

   tbl.findfirst ("where objectid="+format(objectid)+" and FObjId="+format(fatherobjectid))

   where objectid and fatherobjectid are longs and the fields name are objectid and fobjid. i
   should remind you that on the first entry to the recursion it did commit this line and only on
   the second entry it stopped.

   Private Sub RecursTree(ByVal ObjId As Long, ByVal FatherObjId As Long, ByVal level
   As Integer, Table As Recordset, CurrentDb As Database)
   Dim SPrtId As String
   Dim parameterlst As Long
   Dim RetCode As Integer
   Dim Cnt As Integer
   Dim SonsList As Long
   Dim PrtList As Long
   Dim SonPrtList As Long
   Dim PrtClsId As String
   Dim PartClsId As Long
   Dim SObjId As String
   Dim i As Integer
   Dim strquery As String

   parameterlst = RECLST_Create(ApplHndl, 1)
   PrtList = RECLST_Create(ApplHndl, 1)
   SonsList = RECLST_Create(ApplHndl, 1)
   'With Table
   ' strSQL = ("where FObjId=" + Format(FatherObjId) + " and SObjId=" + Format(ObjId))

   '  .FindFirst strSQL
   '  If .NoMatch = True Then
         If FatherObjId <> 0 Then
               Call UpdLinksTbl(FatherObjId, ObjId)
         End If
         With Table
         SObjId = String$(20, " ")
         SPrtId = String$(20, " ")
         PrtClsId = String$(20, " ")
         .AddNew
         !FObjId = FatherObjId
         !SObjId = ObjId
         !level = level
         RetCode = RECLST_AddElValAsPChar(ApplHndl, parameterlst, "1", "CLASS_ID",
   50, TDMT_CHAR)
         strquery = "select CLASS_ID from TN_ITEMS where OBJECT_ID=" + CStr(ObjId)

         RetCode = TDMDB_RunQuery(ApplHndl, strquery, parameterlst,
   TDM_SELFLEXIBLE, PrtList, 0)
         'RECLST_Print ApplHndl, "PrtList", PrtList, 1
         RetCode = RECLST_GetValueByNameAsPChar(ApplHndl, PrtList, "CLASS_ID", 0,
   PrtClsId, 20, "")
         'RetCode = CLS_GetObjClsIdByObjId(ApplHndl, PSupperClsId, ObjId, PartClsId,
   0) as integer
         PrtClsId = Trim(PrtClsId)
         PrtClsId = Mid(PrtClsId, 1, Len(PrtClsId) - 1)
         If Val(PrtClsId) = CPClassId Then
             !Configurable = 1
         Else
             If Val(PrtClsId) = NSPClassId Then
                 !Configurable = 2
             Else
                 !Configurable = 3
             End If
         End If
         .Update
         .Bookmark = .LastModified
       End With
       SonPrtList = RECLST_Create(ApplHndl, 1)
       RetCode = CLS_GetObjectSons(ApplHndl, Val(PrtClsId), ObjId, SonPrtList)
       If RetCode = ERR_NONE Then
         Cnt = RECLST_GetRecordCnt(ApplHndl, SonPrtList)
         If Cnt <> 0 Then
             For i = 1 To Cnt
                 RetCode = RECLST_GetValueByNameAsPChar(ApplHndl, SonPrtList,
   CStr(PSupperClsId) + ".OBJECT_ID", i - 1, SObjId, 20, "")
                 'RECLST_Print ApplHndl, "SonPrtList", SonPrtList, 1
                 Call RecursTree(Val(SObjId), ObjId, level + 1, Table, CurrentDb)
             Next
         End If
       End If
   'End If
   'End With
   RetCode = RECLST_Free(ApplHndl, parameterlst)
   RetCode = RECLST_Free(ApplHndl, SonsList)
   RetCode = RECLST_Free(ApplHndl, PrtList)
   RetCode = RECLST_Free(ApplHndl, SonPrtList)
   End Sub

   Private Sub UpdLinksTbl(FObjectId As Long, ObjectId As Long)
   Dim CurrentDb As Database
   Dim Table As Recordset
   Dim RetCode As Integer
   Dim LinkAttrRecList As Long
   Dim strsql As String
   Dim parameterlist As Long
   Dim Squantity As String

   Squantity = String$(20, " ")
   parameterlist = RECLST_Create(ApplHndl, 1)
   Set CurrentDb = OpenDatabase(configDB)
   Set Table = CurrentDb.OpenRecordset("TreeLinks", dbOpenDynaset)
   LinkAttrRecList = RECLST_Create(ApplHndl, 1)
   'RetCode = CLS_GetHierObjByRelObjIds(ApplHndl, 7, ObjectId, FObjectId,
   LinkAttrRecList, 1)
   'RECLST_Print ApplHndl, "TreeLinks ", LinkAttrRecList, False
   Call RunQAQuery(QClassId, "ITEMS_TREE", "PAR_OBJECT_ID", FObjectId,
   parameterlist) ' possible to replace
   With Table
         RetCode = RECLST_GetValueByNameAsPChar(ApplHndl, parameterlist, CStr(7) +
   ".CN_QUANTITY", 0, Squantity, Len(Squantity) + 1, "")
        .AddNew
        !FObjId = FObjectId
        !SObjId = ObjectId
        !Quantity = Val(Squantity)
        .Update
        .Bookmark = .LastModified
   End With
   RetCode = RECLST_Free(ApplHndl, LinkAttrRecList)
   RetCode = RECLST_Free(ApplHndl, parameterlist)
   Table.Close
   CurrentDb.Close
   End Sub

   this is the code lines. don't mind the commands with Retcode and RECLST_ etc. these are
   api functions of a certain software i'm integrating with. all these commands return correct
   values, they are not the reason for my problem. when i cancel the checking of existing nodes
   i'm getting the right table but a very long one. when i add the find first, it works on the first
   entry to the recursion but then on the next one it says there is a syntax error.
   please help, thank you.
0
Comment
Question by:ilanm
6 Comments
 
LVL 4

Expert Comment

by:idcanada
ID: 1451447

Maybe you can email me a working sample of this.
I am getting many errors simply because I do not have the proper files or actions.
It is hard to debug simply by viewing...

0
 
LVL 3

Expert Comment

by:vikiing
ID: 1451448
I believe the first portion of your message is missing. Could you specify what is the problem you have?
0
 

Author Comment

by:ilanm
ID: 1451449
helo viking
the beggining is :
i try to map atree to a table using vb6. the table is on access 97. i'am doing that by a recursion.

hello idcanada
i can't send you a piece of the code cause you don't have the other software which i integrate with, but the api commands retrieve right values so you can just ignore them and check the vb commands.

thank you very much.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ilanm
ID: 1451450
didn't get an answer
0
 
LVL 2

Accepted Solution

by:
cedricd earned 150 total points
ID: 1451451
.findfirst ("....=... and ... = .... ") (don't use where)
strSQL = ("FObjId=" + Format(FatherObjId) + " and SObjId=" + Format(ObjId))

0
 
LVL 2

Expert Comment

by:cedricd
ID: 1451452
oups :
tbl.findfirst ("objectid="+format(objectid)+" and FObjId="+format(fatherobjectid))

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question