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

Read a Variable as a Literal not a value

Status
Not open for further replies.

marka1966

Programmer
Oct 9, 2002
19
0
0
US
In FoxPro2.6 you can do what is called "Macro Substitution". That is you can set a variable to a value (m.MyString="SELECT * From Dbf01 Where field1=xyz INTO ARRAY qryRay"" and have the contents of the variable executed. (&MyString)

Example:
*****************
If m.MyString="SELECT * From Dbf01 Where field1=xyz INTO ARRAY qryRay"

The command of "&MyString" would actually execute the query

Another Example:
*****************
m.FldTxt="123"
m.MyString="And field2="+m.FldTxt

Select *;
From Dbf01;
Where field1="xyz";
&MyString ;
Into Array qryRay


I am trying to accomplish the same type of thing in VB for an Access query based on field data from a form.



 
Here's how you might do it using ADO after making a reference to the Microsoft ActiveX Data Objects Library:

Dim adoComm As New ADODB.Command
adoComm.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ACCESSFILENAME & ";Persist Security Info=False"
adoComm.CommandText = "your SQL Statement"
adoComm.Execute
 
You can use the execute method of the connection object also. But i have heard it returns a forward only recordset.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top