By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,501 Members | 831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,501 IT Pros & Developers. It's quick & easy.

VB problem with LinkChildField/LinkMasterField

P: n/a
I'm working with Access2002

I'm trying to get the Sub-form to filter correctly programmatically. I've
got the records loading up correctly in the form, and sub-form, with the
exception that the sub-form is displaying all the records instead of the
appropriate sub-set. Whaterver I try with the LinkChild and MasterFields, I
either get no error and no effect or 'RunTime Error 31, Data Provider could
not be initialized'

What is the approprate method for setting these properties? The form and
sub-form are both unbound, and I'm trying to get all bindings done
programatically.

Thanks
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
"Michael Cleroux" <cl*****@rogers.com> wrote in message news:<k0******************@twister01.bloor.is.net. cable.rogers.com>...
I'm working with Access2002

I'm trying to get the Sub-form to filter correctly programmatically. I've
got the records loading up correctly in the form, and sub-form, with the
exception that the sub-form is displaying all the records instead of the
appropriate sub-set. Whaterver I try with the LinkChild and MasterFields, I
either get no error and no effect or 'RunTime Error 31, Data Provider could
not be initialized'

What is the approprate method for setting these properties? The form and
sub-form are both unbound, and I'm trying to get all bindings done
programatically.

Thanks


See this article:
http://www.mvps.org/access/forms/frm0023.htm
Nov 12 '05 #2

P: n/a
You error may be becuase you are trying to bind a sub form to an
unbound parent.
Lets call our forms fParent and fChild. Lets say the subform control
on fParent that holds fChild is called sfChild. Lets say you have a
combo on fParent, cboValue, that gives you the value of a field called
DataField that you want to limit both recordsets by. In cboValue's
AfterUpdate event put something like this assuming DataField is
numeric:
with fParent
.filterOn=true
.filter="[DataField]=" & cboValue
end with
with sfChild.Form
.filterOn=true
.filter="[DataField]=" & cboValue
end with
HTH
Pachydermitis


"Michael Cleroux" <cl*****@rogers.com> wrote in message news:<k0******************@twister01.bloor.is.net. cable.rogers.com>...
I'm working with Access2002

I'm trying to get the Sub-form to filter correctly programmatically. I've
got the records loading up correctly in the form, and sub-form, with the
exception that the sub-form is displaying all the records instead of the
appropriate sub-set. Whaterver I try with the LinkChild and MasterFields, I
either get no error and no effect or 'RunTime Error 31, Data Provider could
not be initialized'

What is the approprate method for setting these properties? The form and
sub-form are both unbound, and I'm trying to get all bindings done
programatically.

Thanks

Nov 12 '05 #3

P: n/a
"Pachydermitis" <de******@hotmail.com> wrote in message
news:4f**************************@posting.google.c om...
You error may be becuase you are trying to bind a sub form to an
unbound parent.


The parent form is not required to be bound in order to properly filter the
subform. While the ChildLink property requires a Field name from the
subform's Recordset, the MasterLink property can be either the name of a
Field in the parents Recordset or the name of a Control on the parent form.
When using the latter, there is no requirement that the Control or the
parent form itself be bound.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #4

P: n/a
When I put in the following line:

Me.chldMembers.LinkMasterFields = "EventID"

where 'EventID' is the name of the control on the parent form, I get 'Data
Provider could not be initialized' error. The same thing happens if I put
in a field name in the sub-form.

Both forms are unbound, and I assign a recordset to both at run-time with
code along the lines of this:

'Specify the connect string
cntConn1.ConnectionString = QueryDetails.Connect
'Open the connection
cntConn1.Open

'Specify the SQL statement
cmd.ActiveConnection = cntConn1

'the SQL statement is listed as a property of QueryDetails
cmd.CommandText = QueryDetails.MemberPartDetail

'Open the recordset
rstMember.CursorLocation = adUseClient
rstMember.Open cmd, , adOpenStatic, adLockOptimistic, adCmdText

Set Me.chldMembers.Form.Recordset = rstMember
Any thoughts?
"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:bu************@ID-98015.news.uni-berlin.de...
"Pachydermitis" <de******@hotmail.com> wrote in message
news:4f**************************@posting.google.c om...
You error may be becuase you are trying to bind a sub form to an
unbound parent.
The parent form is not required to be bound in order to properly filter

the subform. While the ChildLink property requires a Field name from the
subform's Recordset, the MasterLink property can be either the name of a
Field in the parents Recordset or the name of a Control on the parent form. When using the latter, there is no requirement that the Control or the
parent form itself be bound.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 12 '05 #5

P: n/a
"Michael Cleroux" <cl*****@rogers.com> wrote in message
news:Ma*******************@twister01.bloor.is.net. cable.rogers.com...
When I put in the following line:

Me.chldMembers.LinkMasterFields = "EventID"

where 'EventID' is the name of the control on the parent form, I get 'Data Provider could not be initialized' error. The same thing happens if I put in a field name in the sub-form.

Both forms are unbound, and I assign a recordset to both at run-time with
code along the lines of this:


Does the same error occur if you don't assign a Recordset at Runtime?
Perhaps the form is corrupted. If your Recordset assignment is involved I
couldn't hazard a guess as I have never done anything like that.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 12 '05 #6

P: n/a
Yes, I get the same error. I can get the functionality I want by
requerying/refiltering the sub-form every time the main form changes
records, but I keep thinking that there should be a way to get this working
at runtime in a client/server mode with the linked fields.

I mean the recordsets assigned to the two forms contain all the
records/fields required for it to work, why doesn't it?

"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:bu************@ID-98015.news.uni-berlin.de...
"Michael Cleroux" <cl*****@rogers.com> wrote in message
news:Ma*******************@twister01.bloor.is.net. cable.rogers.com...
When I put in the following line:

Me.chldMembers.LinkMasterFields = "EventID"

where 'EventID' is the name of the control on the parent form, I get

'Data
Provider could not be initialized' error. The same thing happens if I

put
in a field name in the sub-form.

Both forms are unbound, and I assign a recordset to both at run-time with code along the lines of this:


Does the same error occur if you don't assign a Recordset at Runtime?
Perhaps the form is corrupted. If your Recordset assignment is involved I
couldn't hazard a guess as I have never done anything like that.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 12 '05 #7

P: n/a
You cannot link subforms to unbound forms. Although it seems like the
way you are doing it is essentially the same thing.
You can get the same effect setting the filter.

"Michael Cleroux" <cl*****@rogers.com> wrote in message news:<Ma*******************@twister01.bloor.is.net .cable.rogers.com>...
When I put in the following line:

Me.chldMembers.LinkMasterFields = "EventID"
'Specify the connect string cntConn1.ConnectionString = QueryDetails.Connect
'Open the connection
cntConn1.Open

'Specify the SQL statement
cmd.ActiveConnection = cntConn1

'the SQL statement is listed as a property of QueryDetails
cmd.CommandText = QueryDetails.MemberPartDetail

'Open the recordset
rstMember.CursorLocation = adUseClient
rstMember.Open cmd, , adOpenStatic, adLockOptimistic, adCmdText

Set Me.chldMembers.Form.Recordset = rstMember
where 'EventID' is the name of the control on the parent form, I get 'Data
Provider could not be initialized' error. The same thing happens if I put
in a field name in the sub-form.

Both forms are unbound, and I assign a recordset to both at run-time with
code along the lines of this:



Any thoughts?
"Rick Brandt" <ri*********@hotmail.com> wrote in message
news:bu************@ID-98015.news.uni-berlin.de...
"Pachydermitis" <de******@hotmail.com> wrote in message
news:4f**************************@posting.google.c om...
You error may be becuase you are trying to bind a sub form to an
unbound parent.


The parent form is not required to be bound in order to properly filter

the
subform. While the ChildLink property requires a Field name from the
subform's Recordset, the MasterLink property can be either the name of a
Field in the parents Recordset or the name of a Control on the parent

form.
When using the latter, there is no requirement that the Control or the
parent form itself be bound.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.