Problems with subform late binding

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,



I have been trying to "late bind" a subform on the page of tab control in
Access, using an example from the Wrox Access 2003 VBA book. However, I
always obtain the same error message when I try my code:



"Data provider could not be initialized"



I have no idea what is happening. The subform used independently works. I
tried a few other things, all revolving around the way LinkChildFields and
LinkMasterFields are allocated, but none worked. Here is the code for the
late binding procedures:



Sub BindSubform(psfrm As SubForm, pstrSourceObject As String,
pstrLinkChildField As String, cstCompID As String)
With psfrm
If Len(.SourceObject) = 0 Then
.SourceObject = pstrSourceObject
.LinkChildFields = pstrLinkChildField
.LinkMasterFields = cstCompID
End If
End With
End Sub
Private Sub tabMain_Change()
Select Case tabMain.Pages(tabMain.Value).Name
Case "pgResults"
If Not (cboLeague.Value = "Select a league") Then
BindSubform subfFixture, "sfrmFixture", "Form![CompID]",
"Form![CompID]"
End If
Case "pgFixtures"

Case "pgStandings"
End Select
End Sub



And, just in case my subform is causing this, here is the code for the load
procedure of the subform:



Private Sub Form_Load()
Dim strSQLFixtures As String
Dim intCounter As Integer

strSQLFixtures = "SELECT A.*, " & _
"(SELECT C.TeamName FROM tblStandings as B, tblTeams as C " & _
"WHERE B.StandID = A.HStandID and B.TeamID = C.TeamID) as
HomeTeam, " & _
"(SELECT C.TeamName FROM tblStandings as B, tblTeams as C " & _
"WHERE B.StandID = A.AStandID and B.TeamID = C.TeamID) as
AwayTeam " & _
"FROM tblFixtures as A " & _
"WHERE GH is NULL and GA is NULL and " & _
"Date <= #" & Format(Date, "m-d-yy") & "#"

Set rsFixtures = ProcessDynamicRecordset(strSQLFixtures)
rsFixtures.Sort = "Date"

Set Me.Form.Recordset = rsFixtures

' The Control Source for each text box on the form is defined directly in
' the text box properties
End Sub



I needed to code the subform this way, as this was the only manner I could
make the subform continuous. All is coded in ADO.



Any kind of help would greatly appreciated.
 
try changing the arguments you supply in the calling code, as

BindSubform subfFixture, "sfrmFixture", "[CompID]",
"[CompID]"

this goes all on one line, of course, even though it line-wrapped in your
post. if the above doesn't work, try removing the brackets from the
fieldnames.

hth
 
Back
Top