How to sum two fields

Keidy

Registered User.
Local time
Today, 16:51
Joined
Dec 5, 2006
Messages
26
:confused: hi!I need help, please. I have problems on how to do a query where i can sum two values of two different fields. Let me explain you better...

table
Column1 Column2 Column3 Column4
Lunes 1 2 4
martes 2 4 2
miercoles 1 1 1

Query
select column1 where (column2+column3)<column4

1+2 =3 4
2+4=6 2
1+1=2 1

results Lunes

That query only have to select monday because is the one where (column2+column3)<column4
 
Try this SQL, it should solve your problem

SELECT Table1.Column1
FROM Table1
WHERE ([Column2]+[Column3])<[Column4];


W1dge
 
thanks

thanks, do you know how to do it in vb, because i have an option group
when i select bajo stock then my subform shows that selection and when i select the other one, the subform changes. do you know how to do it :D
 
Which version of VB? .Net, VB6 or VBA?

If you are using VB6/VBA, I think you can do it using the Openrecordset method of the Recordset class

Off the top of my head, the syntax is something like;

Dim obj as Recordset​

Set obj = OpenRecordset ("SELECT Table1.Column1 FROM Table1 WHERE ([Column2]+[Column3])<[Column4];", dbOpenDynaset)​

I would imagine that .NET would be similar, but I have never done any database programming under .NET I'm afraid.


Hope this helps

W1dge
 
Forgot to add, that you should then set the Source Object property of the subform to be your Recordset object


W1dge
 

Users who are viewing this thread

Back
Top Bottom