query explanation (1 Viewer)

am_sarath

Registered User.
Local time
Today, 13:31
Joined
Sep 19, 2001
Messages
29
hello,

could somebody please tell me what exactly the following lines of code is doing?

Set rsValidate = projectdb.OpenRecordset("Select * from raw_risks where cluster_id=" & lst_clust.Value & " and raw_risk_description Like '" & txt_raw_risk & "'")

If rsValidate.EOF Then
-----------

thank you
 

cogent1

Registered User.
Local time
Today, 13:31
Joined
May 20, 2002
Messages
315
Set rsValidate = projectdb.OpenRecordset("Select * from raw_risks where cluster_id=" & lst_clust.Value & " and raw_risk_description Like '" & txt_raw_risk & "'")

If rsValidate.EOF Then
-----------
It is opening a recordset (rsValidate), which takes all records from a table or query called "raw_risk" which have fields called "cluster_id" that correspond to a value or values displayed in a list box "lst_cluster" (displayed on a form) AND fields that correspond to a raw_risk_description displayed in a text box "txt_raw_risk" , (also probably on the same form).

The last line checks if there are any records. If End Of File is TRUE, there aren't any.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 08:31
Joined
Feb 19, 2002
Messages
43,302
The parts of the query that are enclosed within quotes are literals. The ampersands are used to concatenate the contents of form fields.

Assuming that lst_clust contains 123 and txt_raw_risk = 'desc', the query would look something like the following after the values from the form fields for cluster_id and raw_risk_description are concatenated.

Select * from raw_risks where cluster_id= 123 and raw_risk_description Like '*desc*';
 

Users who are viewing this thread

Top Bottom