subform contained in a main form, is blank even though there is da

R

rum23

My subform (datasheet) view is blank, even though there is data in the table
associated to this subform. The recordsource of the subform is set from the
main form Open() event. What could be wrong?

Thanks much
 
A

Allen Browne

Examine the Link Master Fields and Link Child Fields properties of the
subform control. These may be limiting the subform in a way you did not
intend.

Make sure the subform's Data Entry property is set to No.

If those 2 things don't solve it, and the subform is based on a query, post
the query statement.
 
J

John W. Vinson

My subform (datasheet) view is blank, even though there is data in the table
associated to this subform. The recordsource of the subform is set from the
main form Open() event. What could be wrong?

Thanks much

Check the recordsource! A blank subform means that two conditions are true: 1.
The recordsource doesn't contain any data, so you don't see any existing
records, and 2) it's a non-updateable query, so you don't see the new record
either. What's the Open() event? Why are you setting the recordsource there,
rather than having it be a parameter query, using the master/child link?

Perhaps you could post the code, and try opening the query in query datasheet
view. Maybe it's not giving you the recordset you expect!
 
R

rum23

I have checked the recordsource over and over again and I know its returning
data. I have executed the query in the in the query window and it does return
data.
Subform's dataEntry is set to NO. Link Master Fields and Link Child Fields
of the subform are set correctly. The recordsource of the subform is set like
this


Private Sub Form_Open(Cancel As Integer)

dim qry as string

qry = "SELECT tblCIPBudgetAccounts.CIP_ID,
tblCIPBudgetAccounts.BudgetItemID, tblCIPBudgetAccounts.AccountID, "
qry = qry & "tblCIPBudgetAccounts.AccountCIPAmount ,
tblCIPBudgetAccounts.AccountComments, tlkpAccounts.AccountName "
qry = qry & "from tlkpAccounts Inner join tblCIPBudgetAccounts "
qry = qry & "ON (tlkpAccounts.AccountID = tblCIPBudgetAccounts.AccountID) "
qry = qry & "WHERE CIP_ID ='" & Me.txtCIPID & "' and BudgetItemID = '" &
Me.txtBudgetItemID & "'"

Me![sfrmCIPBudgetAccounts].Form.RecordSource = qry 'sfrmCIPBudgetAccounts is
subform name

exit sub

Thanks
 
R

rum23

Figured it out. My recordsource property setting in the subform was the
culprit. All is working well now.

I can't thank enough to the people who are helping in this message board.


rum23 said:
I have checked the recordsource over and over again and I know its returning
data. I have executed the query in the in the query window and it does return
data.
Subform's dataEntry is set to NO. Link Master Fields and Link Child Fields
of the subform are set correctly. The recordsource of the subform is set like
this


Private Sub Form_Open(Cancel As Integer)

dim qry as string

qry = "SELECT tblCIPBudgetAccounts.CIP_ID,
tblCIPBudgetAccounts.BudgetItemID, tblCIPBudgetAccounts.AccountID, "
qry = qry & "tblCIPBudgetAccounts.AccountCIPAmount ,
tblCIPBudgetAccounts.AccountComments, tlkpAccounts.AccountName "
qry = qry & "from tlkpAccounts Inner join tblCIPBudgetAccounts "
qry = qry & "ON (tlkpAccounts.AccountID = tblCIPBudgetAccounts.AccountID) "
qry = qry & "WHERE CIP_ID ='" & Me.txtCIPID & "' and BudgetItemID = '" &
Me.txtBudgetItemID & "'"

Me![sfrmCIPBudgetAccounts].Form.RecordSource = qry 'sfrmCIPBudgetAccounts is
subform name

exit sub

Thanks

John W. Vinson said:
Check the recordsource! A blank subform means that two conditions are true: 1.
The recordsource doesn't contain any data, so you don't see any existing
records, and 2) it's a non-updateable query, so you don't see the new record
either. What's the Open() event? Why are you setting the recordsource there,
rather than having it be a parameter query, using the master/child link?

Perhaps you could post the code, and try opening the query in query datasheet
view. Maybe it's not giving you the recordset you expect!
 

Ask a Question

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.

Ask a Question

Top