Cor,
Again, this is not what I am after, i do not want to hard code this in
the application ... I want to be able to control this from a database
table - so I do not have to worry about adding the form to the 'code'
form list before I can access it. this would be no different than using
a select statement - it would be another piece of code that needs to be
maintained.
- add row to database (new report)
- create parameter window
- assign user priviledges
... open application, go to report access form, select the form from the
grid view, parameter form opens.
... to me managing this formlist (in code) is an unnecessary step and
becomes maintenance issue (one etrxa place I need to maintain code). By
putting it in the database, I do not need to worry about it - once I test
that forum opens properly.
Kevin G. example (later post) is exactly what I was after.
Private Sub ueShowForm(ByVal aForm As String, ByVal aTitle As String)
Dim ProjectName As String =
Reflection.Assembly.GetExecutingAssembly.GetName.Name
Try
Dim FormType As Type = Type.GetType(ProjectName & "." & aForm)
Dim frmObject As Object = Activator.CreateInstance(FormType)
DirectCast(frmObject, Form).Text = aTitle
DirectCast(frmObject, Form).ShowDialog()
Catch ex As Exception
MessageBox.Show(ex.Message, aForm + " does not exist - CHECK
SPELLING. ")
End Try
End Sub
Cor Ligthert said:
jeff,
You can set all your forms in a table
dim formList as form[] = {Form1, Form2, form3, form4}
dim formNames as String[] = {"OpenForm", "Invoice Form",
"WhateverForm", "OtherForm"}
Search the formnames, take the index and use the form in the formList
with the same index
If you don't understand this, please reply
(You can also set it in a sorted list, use a hashtable, create a class
and than a generic table or an arraylist, however the principle is the
same)
Cor
"jeff" <jhersey at allnorth dottt com> schreef in bericht
what i have is ...
i am building a report access form ... shows a list of all the reports
a user has access to in the application. The form has a treeview
(group > report) and a data grid (list of all the reports). I load the
treeview with a list of all the report groups, I load the datagird with
all the reports. User selects node in treeview, list is
filtered...basic ui functionality.
Now,
each report has a seperate (custom) Parameter Form - allowing the user
to enter criteria for the selected report.
in the database, I store
- master list of reports
- corresponding custom parameter forum.
- user access list (list of reports each user has access to)
So, what I want to do is ...
- code the report access form so that I never have touch the code again
... ( i want to avoid using a select case )
Here was my thought...
- user selects a report to print.
- from the select row, I would get the name of the custom parameter
window (frmReport100_10_parameter)
- store this as a string
- create a temp form, showdialog it, dipose of it.
- done.
I would never have to code this window again. All report showing,
printing, ... would be handled by the custom parameter form.
lParameterForm = row.get.ParameterFormName
Dim lTemp as lParameterForm
lTemp.ShowDialog
lTemp.Dispose
Done.
With this setup, when I add a report to the application, I create the
report, I create the custom parameter window, I add a row to the
database. Done. I do not have to add code the report access form in
order to open the required parameter window...
this is why I would like to do this ...
So, in VB.Net, I can forever make a table of existing forms and select
that ... how do I do this ? Make a Table of Forms and Select that....
this is what I am doing ... at least I thought this is what I am doing.
Again,
Is there a way to ... either ...
iterate through all the forms in may application looking for
'frmReportParameter100_10', find it, showdialogue, close it, dispose
it...
or
get a form type from a table, store it in a string (lFormType), create
an object of type lFormType (ie. 'frmReportParameter100_10'), make the
object realize it is a form and that showdialog is a valid call, call
the method showdialog and dispose of the object.
That is my question - should have included a bit more background in
origonal.
Sorry.
Jeff.
I want to avoid this in my master report access form ...
...
Case "100-01" ' Batch Time Sheet Print.
Dim lFrm As New frmReport100_01
lFrm.ShowDialog()
lFrm.Dispose()
Case "100-02" ' Time Review for a period ... report for Driver
availability
Dim lFrm As New frmReport100_02
lFrm.ShowDialog()
lFrm.Dispose()
Case "110-01" ' Driver Log - Batch print detailed driver log reports.
Dim lFrm As New frmReport110_01
lFrm.ShowDialog()
lFrm.Dispose()
...
Jeff,
VBS and VBA are made for that kind of solutions.
In VB.Net it makes no sence because you can forever make a table with
your existing forms and select that.
Cor
"jeff" <jhersey at allnorth dottt com> schreef in bericht
I would like to do the following ...
Dim lType as String
lType = "frmReport100"
Dim lFrm as lTtype
lFrm.ShowDialog
basically, I want to be able to create a form of type 'StringValue'
... i want to use a string value to define the type of form to open.
Can I do this, and how would it be accomplished.
Thanks
Jeff
DoI need to loop through all the forms in the application ?