Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax error (comma) in my query expression

Status
Not open for further replies.

SheilaAlighieri

Technical User
Nov 16, 2002
68
NL
Hi People!

I have a small problem with my VB code. It has to copy records to another table. It works fine as long as the AmountEuro field contains decimals(for example 2000). But when I try to copy one with decimals (for example 200,05) I get a syntax error. What am I doing wrong?

Thanks!

---------

Private Sub Button__Add__Click()
On Error GoTo Err_Button__Add__Click

Dim rst As ADODB.Recordset
Dim myDte As Date
Set rst = New ADODB.Recordset
rst.ActiveConnection = CurrentProject.Connection
rst.CursorType = adOpenKeyset
rst.LockType = adLockPessimistic

myDte = DateAdd("yyyy", 1, Forms![Data Entry]!InvoiceDte)

If (MsgBox("The system will now copy this invoice to the budget of next year.", vbInformation + vbOKCancel, "Advertising & Promotion Commitment System") = vbOK) Then

rst.Open "SELECT * " _
& "FROM Budget " _
& "WHERE ([Account Code] = " & AccountCode & ") " _
& "AND (BudgetDate = #" & myDte & "#) " _
& "AND (Budget = " & AmountEuro & ") " _
& "AND (Description = '" & Description & "') ;"

-----------
 
Sheila,

I dont know about anyone else, but I don't regard 200,05 as a decimal. 200.05 yes.

e.g. 10.5 = 10 1/2
10,5 = 105 (in my mind)

A period is a decimal point not a comma.
I should think that you will be getting a 'data type error', because 200,5 is really a string - not a number.

Regards,

Darrylle


"Never argue with an idiot, he'll bring you down to his level - then beat you with experience." darrylles@totalise.co.uk
 
Really? I find that rather strange.. so you write down 2,900.75 instead of 2.900,75 (being 2900 3/4)? Still, what can I do to solve this? :(

Sheila
 
I get your point now Darrylle :) But I have no clue where to go from here. All the data in my tables use a comma as the decimal point and it seems to work fine! E.g. 1.5 gives 15, not 1 1/2. Maybe the settings are different.. but for the code to work in VB I need a dot as a decimal point, right?

Thanks for your help!








 
Darylle I got it! Thanks! :) The settings in my country are just different.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top