PC Review


Reply
Thread Tools Rate Thread

update a subform with current data

 
 
placek
Guest
Posts: n/a
 
      16th Apr 2004
hello
i have a subform based on a query, and i run a procedure
that amends the query. The query is named qryBook and the
subform is named fsubBooks.

My hope is that the subform should display the contents of
the query, though this does not happen. Although the query
does update, the subform does not. In order to display the
contents of the query in the subform i have to return to
design view and then to form view. I would like the
subform to update without having to do this. Can anyone
help? My procedure is............

Private Sub Command2_Click()
Dim query As QueryDef
Dim db As Database



Set db = DBEngine(0)(0)
Set query = db.QueryDefs("qryBook")
query.SQL = "select
tblacquisitionrelation.lngacquisitionnumbercnt,
tblbookrelation.strisbn, tblbookrelation.strtitle,
tblbookrelation.strAuthor, tblbookrelation.strcategory,
tblloanrelation.dtmdateborrowed FROM tblloanrelation right
join (tblacquisitionrelation INNER JOIN tblbookrelation ON
tblacquisitionrelation.strisbn=tblbookrelation.strisbn) on
tblloanrelation.lngacquisitionnumbercnt=tblacquisitionrelat
ion.lngacquisitionnumbercnt where isnull
(tblloanrelation.dtmdatereserved) AND not isnull
(tblloanrelation.dtmdateborrowed) OR not isnull
(tblloanrelation.dtmdatereserved) AND not isnull
(tblloanrelation.dtmdateborrowed)"

Me.fsubBooks.Form.Requery
query.Close
db.Close

End Sub

Many Thanks
Martin
 
Reply With Quote
 
 
 
 
Doug Bell
Guest
Posts: n/a
 
      17th Apr 2004
Try

Me.Requery

Also do you need the Query?

stSQL="..............

me.RecordSource=stSQL

This sets the recordsource for the form and does a requery


"placek" <(E-Mail Removed)> wrote in message
news:1d87b01c423bf$ddb0be50$(E-Mail Removed)...
> hello
> i have a subform based on a query, and i run a procedure
> that amends the query. The query is named qryBook and the
> subform is named fsubBooks.
>
> My hope is that the subform should display the contents of
> the query, though this does not happen. Although the query
> does update, the subform does not. In order to display the
> contents of the query in the subform i have to return to
> design view and then to form view. I would like the
> subform to update without having to do this. Can anyone
> help? My procedure is............
>
> Private Sub Command2_Click()
> Dim query As QueryDef
> Dim db As Database
>
>
>
> Set db = DBEngine(0)(0)
> Set query = db.QueryDefs("qryBook")
> query.SQL = "select
> tblacquisitionrelation.lngacquisitionnumbercnt,
> tblbookrelation.strisbn, tblbookrelation.strtitle,
> tblbookrelation.strAuthor, tblbookrelation.strcategory,
> tblloanrelation.dtmdateborrowed FROM tblloanrelation right
> join (tblacquisitionrelation INNER JOIN tblbookrelation ON
> tblacquisitionrelation.strisbn=tblbookrelation.strisbn) on
> tblloanrelation.lngacquisitionnumbercnt=tblacquisitionrelat
> ion.lngacquisitionnumbercnt where isnull
> (tblloanrelation.dtmdatereserved) AND not isnull
> (tblloanrelation.dtmdateborrowed) OR not isnull
> (tblloanrelation.dtmdatereserved) AND not isnull
> (tblloanrelation.dtmdateborrowed)"
>
> Me.fsubBooks.Form.Requery
> query.Close
> db.Close
>
> End Sub
>
> Many Thanks
> Martin



 
Reply With Quote
 
placek
Guest
Posts: n/a
 
      18th Apr 2004
Thanks Doug, but i think i need to explain my form a bit
more. I have a form (Form3) that contains, amoung other
controls, a command button and subform (fsubBooks). I want
to requery fsubBooks when i click the command button. By
doing what you have suggested, will that actually update
the data in fsubBooks? My text book says that it will
requery Form3 as the command button is a control within
this form.

>-----Original Message-----
>Try
>
> Me.Requery
>
>Also do you need the Query?
>
>stSQL="..............
>
>me.RecordSource=stSQL
>
>This sets the recordsource for the form and does a requery
>
>
>"placek" <(E-Mail Removed)> wrote in

message
>news:1d87b01c423bf$ddb0be50$(E-Mail Removed)...
>> hello
>> i have a subform based on a query, and i run a procedure
>> that amends the query. The query is named qryBook and

the
>> subform is named fsubBooks.
>>
>> My hope is that the subform should display the contents

of
>> the query, though this does not happen. Although the

query
>> does update, the subform does not. In order to display

the
>> contents of the query in the subform i have to return to
>> design view and then to form view. I would like the
>> subform to update without having to do this. Can anyone
>> help? My procedure is............
>>
>> Private Sub Command2_Click()
>> Dim query As QueryDef
>> Dim db As Database
>>
>>
>>
>> Set db = DBEngine(0)(0)
>> Set query = db.QueryDefs("qryBook")
>> query.SQL = "select
>> tblacquisitionrelation.lngacquisitionnumbercnt,
>> tblbookrelation.strisbn, tblbookrelation.strtitle,
>> tblbookrelation.strAuthor, tblbookrelation.strcategory,
>> tblloanrelation.dtmdateborrowed FROM tblloanrelation

right
>> join (tblacquisitionrelation INNER JOIN tblbookrelation

ON
>> tblacquisitionrelation.strisbn=tblbookrelation.strisbn)

on
>>

tblloanrelation.lngacquisitionnumbercnt=tblacquisitionrelat
>> ion.lngacquisitionnumbercnt where isnull
>> (tblloanrelation.dtmdatereserved) AND not isnull
>> (tblloanrelation.dtmdateborrowed) OR not isnull
>> (tblloanrelation.dtmdatereserved) AND not isnull
>> (tblloanrelation.dtmdateborrowed)"
>>
>> Me.fsubBooks.Form.Requery
>> query.Close
>> db.Close
>>
>> End Sub
>>
>> Many Thanks
>> Martin

>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select Subform based on Current Data BLW Microsoft Access Form Coding 7 5th Jul 2008 07:02 PM
Getting combo and subform data current on record Rose B Microsoft Access Form Coding 2 11th Dec 2007 12:20 AM
Update Current Record of Subform c.kurutz@comcast.net Microsoft Access Form Coding 2 24th Jan 2007 10:46 PM
Update many fields of the CURRENT record of a subform Céline Brien Microsoft Access Forms 4 4th Aug 2006 03:45 AM
Returning data in a second subform based on first subform current =?Utf-8?B?QWRhbQ==?= Microsoft Access Forms 1 11th May 2006 04:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 PM.