You can, this code will load all fields in all non-system tables into another
table.
Public Sub GetTableInfo()
Dim db As Database
Dim tbl As TableDef
Dim fld As Field
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("TABLE_LIST")
For Each tbl In db.TableDefs
For Each fld In tbl.Fields
If Left$(tbl.Name, 4) <> "MSys" Then
rst.AddNew
rst!TABLE_NAME = tbl.Name
rst!FIELD_NAME = fld.Name
rst.UPDATE
End If
Next fld
Next tbl
End Sub
The major problem is the creation of the formula. Users are still going to
have to enter the formula by hand, either with a keyboard or a long series of
mouse clicks. Overall, I think the keyboard approach is easier.. although
being able to click on a table->field and have it appended to the end of the
text would be a nice touch.
Marco said:
You know what was great? if there's way to have a list with all fields
avaiable in access and users could choose fields from that list.
Maco
:
I've never done this in "production" and what I'm including here was just
thrown together in a few minutes..
Made a form which displayed all the fields from a test table of 10 random
number columns and an ID field.
Under them I had a single text box ( to key in the formula ) and a command
button with the following on click event script:
Private Sub Command4_Click()
Dim sql_string As String
On Error GoTo handler
Me.Text2.SetFocus
sql_string = "SELECT [TEST NUMBERS].[Name], (" & Me.Text2.Text & ") AS
Formula_Result INTO SAMPLE_TABLE FROM [TEST NUMBERS]"
Call DoCmd.RunSQL(sql_string)
Exit Sub
handler:
MsgBox Err.Description
End Sub
I could type in any formula I wanted, such as (field1-field2)/field3 +
(field4-field5)/field3, click the command button and it would create a table
showing the results.
:
Well, it could be.
havind a range of formulas or something like that.
my idea was to give the possibility to my users to create their own formulas.
do you have any example like that?
Marco
:
That's doable, but Access doesn't have a built in interface for that kind of
thing. Depending on how complicated the formulas are getting it could be
rather interesting to make work.
You could display the fields, and have them key a formula into a text box..
and you could parse that string and put it into a SQL statement.
:
I was think something lika having a list of fileds and choosing fields and
number like excel.
Imagine, I could choose (field A / 4) or (field A - field B)
what do you think?
Marco
:
How are you looking to do this? Allowing the user to select from a list of
pre-determined formulas, or enter their own?
:
Hi. I'm currently developing a software to make forecasts.
The way that formulas are calculated are different, it depends of the
department.
Imagine rubric Whater my be a fixed value or it can be calculated based in
other factors.
I would like to have the possibility that my users define how they want the
to calculate the rubric fileds.
Any one know a template based or for finance forecasts?
Regards,
Marco