subform not updating

  • Thread starter Thread starter placek
  • Start date Start date
P

placek

Hi

I'm having some problems with my subform but i don't know
how to solve it. Please take a look.

TblBorrowerRelation has two fields: lngBorrowerNumberCnt
and strBorrowerName. QryBorrowerRelation is based on
tblBorrowerRelation.

Form5 contains a text box, command button and subform
[fsubqryBorrowerRelation]. The subform is based on
qryBorrowerRelation. The user inputs a
Borrower Number in the text box and clicks the command
button. The event handler for the command button updates
qryBorrowerRelation. The code is as follows.


Private Sub Command0_Click()

Dim dbDatabase As Database
Dim qdfQueryDef As QueryDef
Dim varText_Box As Variant

varText_Box = Text5.Value
Set dbDatabase = DBEngine(0)(0)
Set qdfQueryDef = dbDatabase.QueryDefs
("qryBorrowerRelation")
qdfQueryDef.SQL = "select * from tblBorrowerRelation where
tblBorrowerRelation.lngBorrowerNumberCnt=" & varText_Box
me.fsubqryBorrowerRelation.requery

End Sub

The problem is that the sub form does not update after the
command button is clicked. The only way i can get the sub
form to update is by going into design view and then
returning to form view. How can i get the sub form to
update automatically? Any help is much appreciated.

Martin
 
You may be able to solve the issue by requerying the form in the subform
control:
me.fsubqryBorrowerRelation.Form.requery
If the ".Form" bit is new, see:
http://allenbrowne.com/casu-04.html

Alternatively, you could assign the SQL statement directly to the
RecordSource property of the subform:
me.fsubqryBorrowerRelation.Form.RecordSource = "SELECT ...
 
Back
Top