CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 1999
    Posts
    104

    float and findfirst

    I have written some code to check if the value (definded as currency) selected by the user in a combo box, is present in another table, but when the value is a float (, as separator symbol) it gives the error "syntax error (comma) in expression). The variable used for the selected value is [forms]![tarieven].[combo3]
    I have already tried to put that first in a variable that was defined as currency, but that didn' t help.
    Does anyone know how to resolve this problem?



    public Sub controle()
    on error GoTo controle_error
    Dim dbs as Database
    Dim rst as Recordset
    set dbs = CurrentDb
    set rst = dbs.OpenRecordset("Tarieven", dbOpenSnapshot)
    rst.FindFirst "tarief = " & [Forms]![tarieven].[Combo3] & _
    " and sofinr = '" & [Forms]![tarieven].[Sofinr] & "'"

    If rst.NoMatch then
    MsgBox "Tarief kan niet gewijzigd of gewist worden: " & _
    "Verander eerst het standaardtarief", vbOKOnly + vbSystemModal
    Form.Undo
    End If

    controle_exit:
    rst.Close
    Exit Sub

    controle_error:
    MsgBox Err.Number & " " & Err.Description
    GoTo controle_exit
    End Sub




    ps I already posted a message where I said that I had a problem with a combobox and currency values, but now it seems that the error wasn' t in the combobox itself


  2. #2
    Join Date
    May 1999
    Posts
    3,332

    Re: float and findfirst

    try this


    rst.FindFirst "tarief = " & replace([Forms]![tarieven].[Combo3],",",".") & _
    " and sofinr = '" & [Forms]![tarieven].[Sofinr] & "'"



    requires VB 6 (replace).


  3. #3
    Join Date
    Jul 1999
    Posts
    104

    Re: float and findfirst

    thanks for your help.
    Unfortunately I don' t have VB6
    But I find it very strange that I would have to use something like that to do something very simpel.
    Because the problem comes down on something like

    dim test as long
    long = 3,14



    keeping in mind that I use the European standards (, as decimal symbol)
    there hase to be an easy way to do this (I hope).


  4. #4
    Join Date
    Jul 1999
    Posts
    11

    Re: float and findfirst

    Certain conversions (like VAL(..)) assume a "." always, while others (like CSNG(..)) use the separator specified in your windows setup. You might want to look at the MSDN.COM site, or VB Help and search for data conversion info.



  5. #5
    Join Date
    Jul 1999
    Posts
    104

    Re: float and findfirst

    thank you for your reaction. I tried it out, but it don' t works.
    I solved the problem now by converting the ", " with mid() in "."

    myStr = [rsttest]![Standaard-tarief]
    myPos = InStr(1, myStr, ",")
    If myPos <> 0 then
    mid(myStr, myPos, 1) = "." 'This converts "," to "."
    End If

    rst.FindFirst "[Tarief] = " & myStr & _
    "and sofinr = '" & [Forms]![tarieven].[Sofinr] & "'"





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured