Solved

find first problems

Posted on 1998-12-19
6
183 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
Comment Utility

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
Comment Utility
I believe the first portion of your message is missing. Could you specify what is the problem you have?
0
 

Author Comment

by:ilanm
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:ilanm
Comment Utility
didn't get an answer
0
 
LVL 2

Accepted Solution

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

0
 
LVL 2

Expert Comment

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

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now