By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,036 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,036 IT Pros & Developers. It's quick & easy.

insert statement

P: n/a
on sale report I want to make a check if customer doesnot pay full
amount then his dues go in to his account recieveable table. I am
trying this in vba and when I complie it on RunSQL it gives me error
"wrong number of argments", Can any one help plzzz

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue) values(" & _
[Customer], [SaleID], [Due] & ")"

Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On 27 May 2005 05:47:40 -0700, "khan" <ah******@gmail.com> wrote:

Funny characters like # can trip you up. Rather use a field name like
"ReceiptNo".
The best way to debug this is to set a breakpoint on this line,
collect the SQL statement in the debug window, and paste it into a new
query. When you try to run it there, Access will point out the errors
of your ways.

-Tom.

on sale report I want to make a check if customer doesnot pay full
amount then his dues go in to his account recieveable table. I am
trying this in vba and when I complie it on RunSQL it gives me error
"wrong number of argments", Can any one help plzzz

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue) values(" & _
[Customer], [SaleID], [Due] & ")"


Nov 13 '05 #2

P: n/a
With the non alpha numeric character in Reciept#, you may need brackets
([Receipt#]). Also, Receipt is misspelled, if that is causing you a problem.
However, the "wrong number of arguments" is coming from the Values
statement.

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue) values (" & _
[Customer] & ", " & [SaleID] & ", " & [Due] & ")"

--
Wayne Morgan
MS Access MVP
"khan" <ah******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
on sale report I want to make a check if customer doesnot pay full
amount then his dues go in to his account recieveable table. I am
trying this in vba and when I complie it on RunSQL it gives me error
"wrong number of argments", Can any one help plzzz

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue) values(" & _
[Customer], [SaleID], [Due] & ")"

Nov 13 '05 #3

P: n/a

I haven't tested it, but suspect it may be as simple as bad syntax. Try:

If Val(Me!Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,[reciept#],amountDue) values(" & _
[Customer], [SaleID], [Due] & ")"

-Ed

"khan" <ah******@gmail.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
on sale report I want to make a check if customer doesnot pay full
amount then his dues go in to his account recieveable table. I am
trying this in vba and when I complie it on RunSQL it gives me error
"wrong number of argments", Can any one help plzzz

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue) values(" & _
[Customer], [SaleID], [Due] & ")"

Nov 13 '05 #4

P: n/a

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue*) values(" & _
[Customer], [SaleID], [Due] & ")"

my table has ACRID , customerID,reciept# and amountdue
ACRID is an autonumber. can you help

Nov 13 '05 #5

P: n/a
hey guys, my table has 4 fields.
ARCID(autonumber), customerID, reciept#,amountdue.
Dont you think it could be bcz of missing ARCID.

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue*) values (" & _
[Customer] & ", " & [SaleID] & ", " & [Due] & ")"
what do I do about autonumber ARCID.

Nov 13 '05 #6

P: n/a
The Autonumber field isn't a problem, the table will automatically generate
a number for this field as you add each record. The problem is that you need
to pass 3 parameters separated by commas. The way you have your quotation
marks, the commas aren't being passed as part of the SQL string. See my
previous message to fix this.

--
Wayne Morgan
MS Access MVP
"khan" <ah******@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue*) values(" & _
[Customer], [SaleID], [Due] & ")"

my table has ACRID , customerID,reciept# and amountdue
ACRID is an autonumber. can you help
Nov 13 '05 #7

P: n/a
Hey Wayne

Yes you were right but now I am getting another problem here. When i
click button to open my receipt or invoice then it says"You entered an
expression which has no value"
here is all my code

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
DoCmd.SetWarnings False

If ([Reports]![reciept]![Due]) > 0 Then
DoCmd.RunSQL "Insert into
[tblAccountRCA](customerID,reciept#,amountDue) values (" & _
[Customer] & ", " & [SaleID] & ", " & [Due] & ")"
End If

Exit_Report_Open:
Exit Sub

Err_Report_Open:
MsgBox Err.Description
Resume Exit_Report_Open
End Sub

Can you help please

Nov 13 '05 #8

P: n/a
You probably can't get an accurate value for Due in the report's Open event.
I'm assuming this open event is for the Receipt report. Instead, you
probably need to check for this in the Format event of the report section
that uses the Due value. Also, if the report is Receipt, then you don't need
to say Reports!Receipt!Due, you could just shorten that to Me!Due.

--
Wayne Morgan
MS Access MVP
"khan" <ah******@gmail.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hey Wayne

Yes you were right but now I am getting another problem here. When i
click button to open my receipt or invoice then it says"You entered an
expression which has no value"
here is all my code

Private Sub Report_Open(Cancel As Integer)
On Error GoTo Err_Report_Open
DoCmd.SetWarnings False

If ([Reports]![reciept]![Due]) > 0 Then
DoCmd.RunSQL "Insert into
[tblAccountRCA](customerID,reciept#,amountDue) values (" & _
[Customer] & ", " & [SaleID] & ", " & [Due] & ")"
End If

Exit_Report_Open:
Exit Sub

Err_Report_Open:
MsgBox Err.Description
Resume Exit_Report_Open
End Sub

Can you help please

Nov 13 '05 #9

P: n/a
Autonumber fields are just like the name says, each new record will generate
a unique value in the autonumber field.
No user action required.
-Ed

"khan" <ah******@gmail.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
hey guys, my table has 4 fields.
ARCID(autonumber), customerID, reciept#,amountdue.
Dont you think it could be bcz of missing ARCID.

If Val(Me.Due) > 0 Then
DoCmd.RunSQL "Insert into [tblAccountRCA]
(customerID,reciept#,amountDue*) values (" & _
[Customer] & ", " & [SaleID] & ", " & [Due] & ")"
what do I do about autonumber ARCID.
Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.