Solved

find first problems

Posted on 1998-12-19
6
188 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
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…

737 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