Please help me, I am having problem displaying data on an
unlinked sub form.I am using Acess 2003.
The subform not being populated with data though there is data
in the underlying table from which the record source which is
a query for the sub form draws data.
The make up of my program is as follows, mainform (frm_Estimate) and
a Subform (sfrm_Estimate) which are unlinked.
On the main form are text and combo boxes and option buttons and a
command button named “DisplayData”.
in the click event of the command button, is code to pull data from
several tables and the data is stored in a temporary table named
(TBL_Estimate_Parts) based on the selections and input the users makes
on the main form.
The user has to select one of three option buttons which signifies the
product type (1.Fan 2.Parts 3.Box)..
The difference between the product types is just in the tables from where
data is drawn to populate the Temporary table (TBL_Estimate_Parts).
When either (1.Fan) or (2.Parts) is selected all data is correctly displayed
on the subform, but in the case of option 3 (Box) not a single data
(but an empty record ready for editing) is displayed on the subform though
the underlying table (TBL_Estimate_Parts) has data. When I click on the subform
or stored query for the subform both are populated with data.
When run in debug mode, the subform is populated with data (see screenShot004)
which seems to be cleared.
I don’t know when and in which routine that the data is cleared.
What baffles me is that, data is displayed with the same code when option 1 or 2
is selected.
Here is the setup of the main and subform
MainForm (frm_Estimate) Record Source: None、Filter:None
SubForm (sfrm_Estimate) Record Source :Query
SELECT TBL_Estimate_Parts.* FROM TBL_Estimate_Parts ORDER DISPID) Datasheet View RecordSet:
ynaset Filter : None
DUMMY Subform: Record Source: None、Filter:None
Source Object Record Source
ummy
Data Entry : No
unlinked sub form.I am using Acess 2003.
The subform not being populated with data though there is data
in the underlying table from which the record source which is
a query for the sub form draws data.
The make up of my program is as follows, mainform (frm_Estimate) and
a Subform (sfrm_Estimate) which are unlinked.
On the main form are text and combo boxes and option buttons and a
command button named “DisplayData”.
in the click event of the command button, is code to pull data from
several tables and the data is stored in a temporary table named
(TBL_Estimate_Parts) based on the selections and input the users makes
on the main form.
The user has to select one of three option buttons which signifies the
product type (1.Fan 2.Parts 3.Box)..
The difference between the product types is just in the tables from where
data is drawn to populate the Temporary table (TBL_Estimate_Parts).
When either (1.Fan) or (2.Parts) is selected all data is correctly displayed
on the subform, but in the case of option 3 (Box) not a single data
(but an empty record ready for editing) is displayed on the subform though
the underlying table (TBL_Estimate_Parts) has data. When I click on the subform
or stored query for the subform both are populated with data.
When run in debug mode, the subform is populated with data (see screenShot004)
which seems to be cleared.
I don’t know when and in which routine that the data is cleared.
What baffles me is that, data is displayed with the same code when option 1 or 2
is selected.
Here is the setup of the main and subform
MainForm (frm_Estimate) Record Source: None、Filter:None
SubForm (sfrm_Estimate) Record Source :Query
SELECT TBL_Estimate_Parts.* FROM TBL_Estimate_Parts ORDER DISPID) Datasheet View RecordSet:

DUMMY Subform: Record Source: None、Filter:None
Source Object Record Source

Data Entry : No
Code:
Private Sub DisplayData_Click()
Dim qdefrs1 As DAO.QueryDef
DoCmd.SetWarnings False
On Error GoTo ErrorHandler
Set db = OpenDatabase("C:\Estimate.mdb")
Stq = "DELETE * FROM TBL_Estimate_Parts" ' Delete all data in temp file
DoCmd.RunSQL Stq
K_Estimate.SourceObject = "" ' Resetting the SourceObject
Set rs1 = qdefrs1.OpenRecordset()
Set rs2 = db.OpenRecordset("TBL_Estimate_Parts", dbOpenDynaset)
If Not (rs1.BOF And rs1.EOF) Then
rs1.MoveFirst
End if
Do Until rs1.EOF
On Error GoTo ErrorHandler
rs2.AddNew
rs2!Model = NZ(rs1("Model"))
rs1.MoveNext
Loop
K_Estimate.SourceObject = "Sfrm_Estimate" ' Setting the SourceOBject
Me.K_Estimate.Requery
Me.K_Estimate.Form.Recordset.MoveFirst
rs1.Close: Set rs1 = Nothing
‘rs2.Close: Set rs2 = Nothing
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err = 3021 Then
Resume Next
Else
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
End If
End Sub