i want to run this Query with ADODC control and show result in Datagird View

Private Sub Command1_Click()
Dim Sell_tbl, Stock_Bottle, res As String


Sell_tbl = "SELECT Sum((Quantity)*12) FROM Sell_Detail Where Cateogry='Large'"
Stock_Bottle = "Select Sum(No_Of_Bottle) FROM Add_Bottle Where Cateogry='Large'"

res = ((Sell_tbl) - (Stock_Bottle))

Adodc1.RecordSource = Sell_tbl
Adodc1.Refresh
Adodc1.Caption = Adodc1.RecordSource
End Sub

Error show
Type Mismatch

Only glancing at it, you declared your variables as string but then try to do some calculation with these in line 8. Need to change into some number type, int, long ?

I CONVERT IT INTO int datatype but still not working

Your select statements could be also wrong. May be try:
"SELECT Sum((Quantity)12) FROM Sell_Detail Where Cateogry=" & "'" & Large & "'" and I am not sure if you have take this Sum((Quantity)12) also out of the string.

my queries are running fines when I run Only one Query else when i combine them to ind sum it shows error..
Syntax error Missing operator

or Quotes are nested what i experience Because by your previously post i just remove them and i got error..

Well I would put some error checking in. After each select statement use debug.print() to see if your selects return what you expect. MAybe googlee for some select statement code and compare this to what you've got becxause I don't think you got it correct.

Thanks about debug.print but the problem is still remain it couldn't subtract one query reult with the other Please Help

Well, do you know what is returned?

I suggest you use ADODB for this one.

Read THIS.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.