Hi all,
Pull up a chair, this will take a while to explain......
I'm currently developing a form in my database that will operate in a similar way to the expression builder available when writing a query, this form will allow me to write SQL statements on the fly.
What I have is a form with 1 text box, which I call SQLScript, 2 list boxes, which I call tables and fields respectively. The first list called "tables", contains a listing of the tables in my database using the MsysObjects table.
The second list called "fields" contains a dynamic listing of the fields within the tables. What this means, is that after clicking on the requested table in the "tables" listbox an afterupdate event runs which lists the fields within that table in the "fields"
Attached to both tables are doubleclick routines that insert the values into the SQLScript textbox. When you doubleclick on a field in the "tables" list box the table name will be inserted and when you doubleclick on a field in the "fields" listbox. The table name, a period, and the field name are inserted (tablename.fieldname).
With me so far? Well, what I've also created are few little buttons that insert reserved words like and not = and so on and also ones that insert the rough guts of different SQL statements. For instance you click the MAKE button and the following 'base statement'is inserted automatically into the SQLScript textbox:
Leaving the user to basically fill in the blanks
Because I've got this button that inserts the values into the SQLScript text box. My first problem was to overcome overwriting the statement everytime I click on one of the buttons. To get around this, I created 2 hidden text boxes. When a button or table/field is clicked, the data keyed into 'SQLScript' is inserted into 1 text box. The value behind the button/value clicked is inserted into text box 2 then both values are concatenated back into 'SQLScript' (text1 & " " & text2).
Can anyone see the problem yet?
The problem, is that when I click on the button and insert a 'base statement' and then click on the button or table/field to insert one of those values. The value clicked is always inserted after whatever text is already in there. So I get:
SELECT
INTO tbl_SQLResults
FROM ; tbl_Employees.EmpNo
Instead of:
SELECT tbl_Employees.EmpNo
INTO tbl_SQLResults
FROM ;
What I really want is a way to have the insert based on where the cursor was positioned in that field (I say was because I click out of the field in order to click on a button, value or field.
Another question that I wanted to ask was; the SQL statements being generated modify a table called tbl_SQLResults. What I wanted to know was, how can I have a table created automatically for inserting the results of the query and deleted when the form is closed?
Well I've certainly said enough. Hope your still awake.....
Oh, and the verions of access that I'm using is access 2k
Thanks, tadynn
Pull up a chair, this will take a while to explain......
I'm currently developing a form in my database that will operate in a similar way to the expression builder available when writing a query, this form will allow me to write SQL statements on the fly.
What I have is a form with 1 text box, which I call SQLScript, 2 list boxes, which I call tables and fields respectively. The first list called "tables", contains a listing of the tables in my database using the MsysObjects table.
The second list called "fields" contains a dynamic listing of the fields within the tables. What this means, is that after clicking on the requested table in the "tables" listbox an afterupdate event runs which lists the fields within that table in the "fields"
Attached to both tables are doubleclick routines that insert the values into the SQLScript textbox. When you doubleclick on a field in the "tables" list box the table name will be inserted and when you doubleclick on a field in the "fields" listbox. The table name, a period, and the field name are inserted (tablename.fieldname).
With me so far? Well, what I've also created are few little buttons that insert reserved words like and not = and so on and also ones that insert the rough guts of different SQL statements. For instance you click the MAKE button and the following 'base statement'is inserted automatically into the SQLScript textbox:
Leaving the user to basically fill in the blanks
Because I've got this button that inserts the values into the SQLScript text box. My first problem was to overcome overwriting the statement everytime I click on one of the buttons. To get around this, I created 2 hidden text boxes. When a button or table/field is clicked, the data keyed into 'SQLScript' is inserted into 1 text box. The value behind the button/value clicked is inserted into text box 2 then both values are concatenated back into 'SQLScript' (text1 & " " & text2).
Can anyone see the problem yet?
The problem, is that when I click on the button and insert a 'base statement' and then click on the button or table/field to insert one of those values. The value clicked is always inserted after whatever text is already in there. So I get:
SELECT
INTO tbl_SQLResults
FROM ; tbl_Employees.EmpNo
Instead of:
SELECT tbl_Employees.EmpNo
INTO tbl_SQLResults
FROM ;
What I really want is a way to have the insert based on where the cursor was positioned in that field (I say was because I click out of the field in order to click on a button, value or field.
Another question that I wanted to ask was; the SQL statements being generated modify a table called tbl_SQLResults. What I wanted to know was, how can I have a table created automatically for inserting the results of the query and deleted when the form is closed?
Well I've certainly said enough. Hope your still awake.....
Oh, and the verions of access that I'm using is access 2k
Thanks, tadynn