Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a query dynamically

Tags:

vba

ms-access

Hi I need to create a query in MSAccess 2003 through code (a.k.a. VB) -- how can I accomplish this?

like image 365
Andrew G. Johnson Avatar asked Dec 23 '08 23:12

Andrew G. Johnson


People also ask

How do I create a dynamic select query in SQL?

Syntax for dynamic SQL is to make it string as below : 'SELECT statement'; To run a dynamic SQL statement, run the stored procedure sp_executesql as shown below : EXEC sp_executesql N'SELECT statement';

What is a dynamic query?

Dynamic queries refer to queries that are built dynamically by Drupal rather than provided as an explicit query string. All Insert, Update, Delete, and Merge queries must be dynamic. Select queries may be either static or dynamic. Therefore, "dynamic query" generally refers to a dynamic Select query.


1 Answers

A vague answer for a vague question :)

strSQL="SELECT * FROM tblT WHERE ID =" & Forms!Form1!txtID 

Set qdf=CurrentDB.CreateQueryDef("NewQuery",strSQL)
DoCmd.OpenQuery qdf.Name
like image 86
Fionnuala Avatar answered Sep 18 '22 00:09

Fionnuala