C/Front Setcurrentkey

carlo.mynycarlo.myny Member Posts: 8
I try to get the records of a table in a specific order.
So Setcurrentkey could help me do this.
There is a key defined in NAV but I do not know what to give to the SetCurrentkey as parameter.
1st parameter is the table, but the second is the key. But what shoukd be the value of the key. Must this bey the fieldnumber of the field on which the key in NAV is defined or the field number of the field in the overview of the keys.

example: If I look at the keys on a specific tabel there are for example 3 keys:
No.
Country
City

If I want city do I use 3 as Key value or do I use CF.FieldNo(Table, "City") as valu of the parameter Key.

I tried both ways but the records are not returned sorted as I want to.

Comments

  • BeliasBelias Member Posts: 2,998
    you should read the application developer guide before programming nav...
    to answer your questio, press F1 in the C/AL designer and search "setcurrentkey"..you'll obtain the syntax.
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • carlo.mynycarlo.myny Member Posts: 8
    Belias wrote:
    you should read the application developer guide before programming nav...
    to answer your questio, press F1 in the C/AL designer and search "setcurrentkey"..you'll obtain the syntax.

    It is not in NAV that I do this , it is in Microsoft office Word using VBA and the C/Front OCX. So the help of C/AL will not help me in this case.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Belias wrote:
    you should read the application developer guide before programming nav...
    to answer your questio, press F1 in the C/AL designer and search "setcurrentkey"..you'll obtain the syntax.
    Are you sure F1 covers C/FRONT?
    David Singleton
  • BeliasBelias Member Posts: 2,998
    i didn't read the title of the topic... :whistle: :oops:
    it was strange, as i've seen that carlo joined mibuso in 2003...sorry.
    P.S.: i've no experience with c/front, but i think you have to pass the table and the "cardinal" number of the key (i don't know if it starts from 0 or 1). About your example, if you want to use "city" key i think you have to pass (table,3(or 2))
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • carlo.mynycarlo.myny Member Posts: 8
    Belias wrote:
    i didn't read the title of the topic... :whistle: :oops:
    it was strange, as i've seen that carlo joined mibuso in 2003...sorry.
    P.S.: i've no experience with c/front, but i think you have to pass the table and the "cardinal" number of the key (i don't know if it starts from 0 or 1). About your example, if you want to use "city" key i think you have to pass (table,3(or 2))

    I tried 3 already but no result. I tried 2 now but still no change in the sorting of the result.


    Someone else who has experience with this.
  • kapamaroukapamarou Member Posts: 1,152
    From the help I see that C/Front SetCurrentKey accepts an array with the key fields:

    From the help file:
    Syntax
    Function SetCurrentKey(ByVal hTable As Long, ByVal Key As Variant) As Boolean
    hTable
    The handle to the table.
    Key
    The desired key or an empty variant.
    Example
      CF1.OpenTable hTable, 18 ' customer table
      longArray(0) = 1 ' field: "No."
      longArray(1) = 3 ' field: "Search Name"
      longArray(2) = 0
      tmpVar = longArray
      tmpVar2 = CF1.SetCurrentKey(hTable, tmpVar)
      If VarType(tmpVar2) <> vbBoolean Then
      logWr "SetCurrentKey failed. It didn't return a boolean"
      End If
      CF1.CloseTable hTable
    
Sign In or Register to comment.