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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using results of a query in VB

Status
Not open for further replies.

daem

IS-IT--Management
Jul 18, 2001
2
LU
OK, a very trivial problem here i am sure.... how do i use the results of an ´query within VB. Normally i would just hardcode a procedure to swcan through a table in VB, but i want to use an SQL query this time. I have tested it works, and the result is an integer... how do i then assign this to a variable???

My query is:
SELECT Max([Component_Line].[Component_Line])FROM Component_Line WHERE ((Component_Line.Config_Id)=1);

so i will run this using the run sql command but if someone could tell me how to then use thew result i would be very grateful... i have a feeling it has something to do settiong a variable to recordset!!!

Thanks,
Daem
 
You can use the DMax function to assign the result of a "query/sql statement" to a variable. You don't need your SQL statement in this example, it just provided me the proper syntax to get the max of Component_Line where Config_ID = 1.

MyVariable = DMax("[Component_Line]","Component_Line","[Config_ID]=1")

HTH Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top