Findfirst + multiple criteria ???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • @ndy

    Findfirst + multiple criteria ???

    Hey, this is the situation. I have imported a table from Excel and
    know i must edit the saldo in the corresponding records tbl_Lignes.

    Impdata tbl_Lignes
    ............... ....... ............... ....
    File_nr Product saldo Dos_nr Line_nr saldo
    -------- -------- ------ ------- ------- -----
    123456 1 10 123456 1 ..
    2 70 2 ..
    3 65 3 ..
    123457 1 50 123457 1
    123458 1 40 123458 1
    2 20 2

    I loop through the Imptable and want to search the similar File nr
    with the corresponding product nr in the tbl_Lignes and this with a
    Findfirst.

    I have wrote this and gives no errors but he doesn't find the
    corresponding record.

    ......
    ......
    Do While Not rstImpdata.EOF
    strSeek = ""
    strSeekDos = rstImpdata![File_nr]
    strSeek = "Dos_nr = '" & strSeekDos & "'"
    If (strSeek = strVgl) Then

    With rstLignes
    strLnr = ""
    strLnr = rstLignes![Line_nr]

    strSeek1 = "Dossier_Id = '" & strSeek & "' AND Ligne_Num = '" & strLnr
    & "'"

    .FindFirst strSeek1
    !!!'HE DOESN'T FIND FILE_NR 123456 WITH Product 1 IN tbl_Lignes!!!!

    If .NoMatch Then
    MsgBox "No Ligne found in tbl_Ligne for " & strSeek1 &
    "."
    Else
    .Edit
    rstLignes![saldo] = rstImpdata![saldo]
    .Update
    .MoveNext
    End If
    End With
    Else
    .....
    .....

    What is wrong?? I' don't know it anymore.
  • @ndy

    #2
    Re: Findfirst + multiple criteria ???

    andyvandw@hotma il.com (@ndy) wrote in message news:<6ce3148b. 0411300231.aedc 217@posting.goo gle.com>...[color=blue]
    > Hey, this is the situation. I have imported a table from Excel and
    > know i must edit the saldo in the corresponding records tbl_Lignes.
    >
    > Impdata tbl_Lignes
    > ............... ...... ............... ....
    > File_nr Product saldo Dos_nr Line_nr saldo
    > -------- -------- ------ ------- ------- -----
    > 123456 1 10 123456 1 ..
    > 2 70 2 ..
    > 3 65 3 ..
    > 123457 1 50 123457 1
    > 123458 1 40 123458 1
    > 2 20 2
    >
    > I loop through the Imptable and want to search the similar File nr
    > with the corresponding product nr in the tbl_Lignes and this with a
    > Findfirst.
    >
    > I have wrote this and gives no errors but he doesn't find the
    > corresponding record.
    >
    > .....
    > .....
    > Do While Not rstImpdata.EOF
    > strSeek = ""
    > strSeekDos = rstImpdata![File_nr]
    > strSeek = "Dos_nr = '" & strSeekDos & "'"
    > If (strSeek = strVgl) Then
    >
    > With rstLignes
    > strLnr = ""
    > strLnr = rstLignes![Line_nr]
    >
    > strSeek1 = "Dossier_Id = '" & strSeek & "' AND Ligne_Num = '" & strLnr
    > & "'"
    >
    > .FindFirst strSeek1
    > !!!'HE DOESN'T FIND FILE_NR 123456 WITH Product 1 IN tbl_Lignes!!!!
    >
    > If .NoMatch Then
    > MsgBox "No Ligne found in tbl_Ligne for " & strSeek1 &
    > "."
    > Else
    > .Edit
    > rstLignes![saldo] = rstImpdata![saldo]
    > .Update
    > .MoveNext
    > End If
    > End With
    > Else
    > .....
    > .....
    >
    > What is wrong?? I' don't know it anymore.[/color]

    I have the same problem!!

    Comment

    • Tom van Stiphout

      #3
      Re: Findfirst + multiple criteria ???

      On 30 Nov 2004 02:31:28 -0800, andyvandw@hotma il.com (@ndy) wrote:

      In strSeek you're calling the first field Dossier_Id, whereas in your
      table example you're calling it Dos_nr. Same with Ligne_Num and
      Line_nr.

      The quotes around the values are only correct if these are text
      fields. If they really only can contain numbers, convert them to
      numeric.

      Text fields sometimes have leading or trailing spaces, so be careful
      when looking for the exact string "1" where you may have "1 " in the
      table.

      Nothing you have shown in this example couldn't be done with an Update
      query, in a fraction of the time.

      -Tom.



      [color=blue]
      >Hey, this is the situation. I have imported a table from Excel and
      >know i must edit the saldo in the corresponding records tbl_Lignes.
      >
      >Impdata tbl_Lignes
      >.............. ....... ............... ....
      >File_nr Product saldo Dos_nr Line_nr saldo
      >-------- -------- ------ ------- ------- -----
      >123456 1 10 123456 1 ..
      > 2 70 2 ..
      > 3 65 3 ..
      >123457 1 50 123457 1
      >123458 1 40 123458 1
      > 2 20 2
      >
      >I loop through the Imptable and want to search the similar File nr
      >with the corresponding product nr in the tbl_Lignes and this with a
      >Findfirst.
      >
      >I have wrote this and gives no errors but he doesn't find the
      >correspondin g record.
      >
      >.....
      >.....
      >Do While Not rstImpdata.EOF
      > strSeek = ""
      > strSeekDos = rstImpdata![File_nr]
      > strSeek = "Dos_nr = '" & strSeekDos & "'"
      > If (strSeek = strVgl) Then
      >
      > With rstLignes
      > strLnr = ""
      > strLnr = rstLignes![Line_nr]
      >
      >strSeek1 = "Dossier_Id = '" & strSeek & "' AND Ligne_Num = '" & strLnr
      >& "'"
      >
      > .FindFirst strSeek1
      >!!!'HE DOESN'T FIND FILE_NR 123456 WITH Product 1 IN tbl_Lignes!!!!
      >
      > If .NoMatch Then
      > MsgBox "No Ligne found in tbl_Ligne for " & strSeek1 &
      >"."
      > Else
      > .Edit
      > rstLignes![saldo] = rstImpdata![saldo]
      > .Update
      > .MoveNext
      > End If
      > End With
      > Else
      > .....
      > .....
      >
      >What is wrong?? I' don't know it anymore.[/color]

      Comment

      Working...