Solved

find first problems

Posted on 1998-12-19
6
186 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Updates not working for MS Windows 7 12 166
Adding to a VBA? 6 70
fso.FolderExists("\\server\HiddenFolder$") 4 65
Publisher:   Unknown     VB.exe Application 1 21
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…

777 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