0

In DataEnvironment I have a Command Object in which I have given following SQL Query:

SELECT * FROM userdetails WHERE Date = Todays_date

Here Todays_date is a public variable in Module. This variable accepts value at run-time.

How to call variable in DataEnvironment's SQL Query?

1 Answer 1

1

The VB6 manuals cover this in Closing and Reopening the Recordset under the heading Data Environment Programming Guidelines. The example given there looks like:

Option Explicit

Private Sub Command1_Click()
    ' You must close the recordset before changing the parameter.
    If DataEnvironment1.rsCommandQuery.State = adStateOpen Then
        DataEnvironment1.rsCommandQuery.Close
    End If
    ' Reopen the recordset with the input parameter supplied by
    ' the TextBox control.
    DataEnvironment1.CommandQuery Text1.Text
    With Text2
        .DataField = "AU_LName"
        .DataMember = "CommandQuery"
        Set .DataSource = DataEnvironment1
    End With
End Sub

Private Sub Form_Load()
    ' Supply a default value.
    Text1.Text = "172-32-1172"
    ' Change the CommandButton caption.
    Command1.Caption = "Run Query"
End Sub

You call the Command object as a method of its parent DataEnvironment, passing the parameters there. Gotta love The Fine Manual.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.