J
John F
Is it possible to display multiple instances of an access form and if so how
is this done?
John.
is this done?
John.
On the second instance, it changes the subform's (Child16)
sourceobject to a different subform. [...]
With frm2 [...]
.Controls("Child16").SourceObject = "sbfrmAdditives"
End With
Dirk Goldgar said:[...]On the second instance, it changes the subform's (Child16)
sourceobject to a different subform. [...]
With frm2 [...]
.Controls("Child16").SourceObject = "sbfrmAdditives"
End With
But that is not what the OP was asking, and what Graham was saying
couldn't be done. Specifically, the OP asked,
As I interpret this, and I think it's also how Graham understood it, the
OP would like to be able to do something like this:
<BEGIN INVALID CODE>
Dim frm As Form
' Create an instance of the form to be used as a subform.
Set frm = LibraryDatabase.FormFactory("SomeForm")
Set .Controls("SubformName").SourceObject = frm
<END INVALID CODE>
But you can't do that; at least, not using any normal method. I suppose
it might be possible by manipulating memory with pointers and such, but
it would be very difficult at best.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Dirk Goldgar said:[...]On the second instance, it changes the subform's (Child16)
sourceobject to a different subform. [...]
With frm2 [...]
.Controls("Child16").SourceObject = "sbfrmAdditives"
End With
But that is not what the OP was asking, and what Graham was saying
couldn't be done. Specifically, the OP asked,
As I interpret this, and I think it's also how Graham understood it, the
OP would like to be able to do something like this:
<BEGIN INVALID CODE>
Dim frm As Form
' Create an instance of the form to be used as a subform.
Set frm = LibraryDatabase.FormFactory("SomeForm")
Set .Controls("SubformName").SourceObject = frm
<END INVALID CODE>
But you can't do that; at least, not using any normal method. I suppose
it might be possible by manipulating memory with pointers and such, but
it would be very difficult at best.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Ed Adamthwaite said:Hi Dirk,
Yes, I bypassed the point about using a string, to me it still doesn't
matter. If you change the code of the second instance to:
Static frm2 As Form
Set frm2 = New Form_frmAdditivesAndInnerIngr
With frm2
.Visible = True
.Caption = "Hello Again SIG!"
.Detail.BackColor = vbRed
.Controls("lblSort").BackColor = vbRed
.Controls("Child16").SourceObject = Form_sbfrmAdditives.Name
End With
We are still referencing it as a string (sbfrm.Name), but a literal
string is not used.
If you open a completely empty database and
reference the database with this code in it, it still runs without a
problem.
Ed Adamthwaite said:Hi Dirk,
Yes, I bypassed the point about using a string, to me it still doesn't
matter. If you change the code of the second instance to:
Static frm2 As Form
Set frm2 = New Form_frmAdditivesAndInnerIngr
With frm2
.Visible = True
.Caption = "Hello Again SIG!"
.Detail.BackColor = vbRed
.Controls("lblSort").BackColor = vbRed
.Controls("Child16").SourceObject = Form_sbfrmAdditives.Name
End With
We are still referencing it as a string (sbfrm.Name), but a literal string
is not used. If you open a completely empty database and reference the
database with this code in it, it still runs without a problem.
We can still change the subform by code by doing the same with the altered
"changesubform" procedure below.
You don't even have to Requery the form.
Sub changesubform()
Dim frm As Form
Dim i As Integer
i = 0
For Each frm In Forms
Set frm = Forms(i)
If frm.Caption = "Hello Again SIG!" Then Exit For
i = i + 1
Next
frm.Controls("Child16").SourceObject =
Form_sbfrmAdditiveAndInnerIngrWarnings.Name
'frm.Requery
Set frm = Nothing
End Sub
The only problem is that you need to have the code in the referenced
database. Graham is correct if the code is in the referencing database.
From what I have found it seems that Form Objects are not passed to the
VBA IDE via the reference, only modules with their types, enums,
properties and methods. It would be nice if it could, but this could open
up a few more security issues to contend with.
Cheers,
Ed.
Dirk Goldgar said:[...]On the second instance, it changes the subform's (Child16)
sourceobject to a different subform. [...]
With frm2 [...]
.Controls("Child16").SourceObject = "sbfrmAdditives"
End With
But that is not what the OP was asking, and what Graham was saying
couldn't be done. Specifically, the OP asked,
does anyone know if there's a way to set
the'SourceObject' of a subform from code, using a reference to a
form instance? Access only seems to allow it to be set via the form
name (specified as a string), which is no good if the required
sub-form is in a
referenced library database. If it's possible, it'd be the cure to
a big headache for me!
As I interpret this, and I think it's also how Graham understood it, the
OP would like to be able to do something like this:
<BEGIN INVALID CODE>
Dim frm As Form
' Create an instance of the form to be used as a subform.
Set frm = LibraryDatabase.FormFactory("SomeForm")
Set .Controls("SubformName").SourceObject = frm
<END INVALID CODE>
But you can't do that; at least, not using any normal method. I suppose
it might be possible by manipulating memory with pointers and such, but
it would be very difficult at best.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
...is not the same instance as... it's not supposed to be...
.Controls("Child16").SourceObject = Form_sbfrm_whatever <--the subform
Graham R Seach said:Ed,
But you're not referencing the same form instance!
Using Set frm = New Form_whatever
...is not the same instance as...
.Controls("Child16").SourceObject = Form_whatever
If you could set it as follows, it would be what the OP wanted:
.Controls("Child16").SourceObject = frm
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
Ed Adamthwaite said:Hi Dirk,
Yes, I bypassed the point about using a string, to me it still doesn't
matter. If you change the code of the second instance to:
Static frm2 As Form
Set frm2 = New Form_frmAdditivesAndInnerIngr
With frm2
.Visible = True
.Caption = "Hello Again SIG!"
.Detail.BackColor = vbRed
.Controls("lblSort").BackColor = vbRed
.Controls("Child16").SourceObject = Form_sbfrmAdditives.Name
End With
We are still referencing it as a string (sbfrm.Name), but a literal
string is not used. If you open a completely empty database and reference
the database with this code in it, it still runs without a problem.
We can still change the subform by code by doing the same with the
altered "changesubform" procedure below.
You don't even have to Requery the form.
Sub changesubform()
Dim frm As Form
Dim i As Integer
i = 0
For Each frm In Forms
Set frm = Forms(i)
If frm.Caption = "Hello Again SIG!" Then Exit For
i = i + 1
Next
frm.Controls("Child16").SourceObject =
Form_sbfrmAdditiveAndInnerIngrWarnings.Name
'frm.Requery
Set frm = Nothing
End Sub
The only problem is that you need to have the code in the referenced
database. Graham is correct if the code is in the referencing database.
From what I have found it seems that Form Objects are not passed to the
VBA IDE via the reference, only modules with their types, enums,
properties and methods. It would be nice if it could, but this could open
up a few more security issues to contend with.
Cheers,
Ed.
Dirk Goldgar said:[...]
On the second instance, it changes the subform's (Child16)
sourceobject to a different subform.
[...]
With frm2
[...]
.Controls("Child16").SourceObject = "sbfrmAdditives"
End With
But that is not what the OP was asking, and what Graham was saying
couldn't be done. Specifically, the OP asked,
does anyone know if there's a way to set
the'SourceObject' of a subform from code, using a reference to a
form instance? Access only seems to allow it to be set via the form
name (specified as a string), which is no good if the required
sub-form is in a
referenced library database. If it's possible, it'd be the cure to
a big headache for me!
As I interpret this, and I think it's also how Graham understood it, the
OP would like to be able to do something like this:
<BEGIN INVALID CODE>
Dim frm As Form
' Create an instance of the form to be used as a subform.
Set frm = LibraryDatabase.FormFactory("SomeForm")
Set .Controls("SubformName").SourceObject = frm
<END INVALID CODE>
But you can't do that; at least, not using any normal method. I suppose
it might be possible by manipulating memory with pointers and such, but
it would be very difficult at best.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.