0
insert into po_detail (item_code,qty,item_rate,item_tax) select a.item_code,qty,item_rate,item_tax from mr_detail a,mr_head b where a.mr_no = " & combo_mr_no.Text & " and a.mr_no=b.mr_no""

what's the error in the above code ?

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

If item_code, qty, item_rate and item_tax are unique then they don't have to be qualified (as in with a. or b. but it is good practice to qualify them anyway for clarity.

You didn't give the entire line of code. You are building a string query but I can't see the assignment or even the opening quotes so I can't speak as to syntax. You also need to surround text values in single quotes. I find it helps to format query strings so each portion of a clause is on its own line. It makes it easier to read and spot syntax errors. Replace the ?. in the following with the appropriate qualifiers (a., b.) and try

query = "insert into po_detail (item_code,qty,item_rate,item_tax)" _
      & "  select  a.item_code, ?.qty, ?.item_rate, ?.item_tax" _
      & "    from  mr_detail a, mr_head b" _
      & "    where a.mr_no = b.mr_no" _
      & "      and a.mr_no = '" & combo_mr_no.Text & "'"

Edited by Reverend Jim: n/a

0

I think you miss the "Values()" part.

Insert Into Table1(Field1,Field2,.....) Values(Val1,Val2,.....)

This is the correct form of SQL Insert...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.