PC Review


Reply
Thread Tools Rate Thread

Can't refresh report in code.

 
 
=?Utf-8?B?QWxsZW5fTg==?=
Guest
Posts: n/a
 
      21st Feb 2007
I am changing the RecordSource and unbound text boxes in a report using code,
but i can't get the unbound controls to refresh automatically. I can manually
switch to Design Mode and back to Preview, but closing and opening the report
in code doesn't work.

The only sequence that doesn't throw errors is as follows:

DoCmd.OpenReport strKillKitReport, acViewDesign, , , acHidden
Set repHost = Reports(strKillKitReport)
strSQL = "SELECT ID, KitGroup1, KitItem, Descr, Franchise, " & _
"Item, DescrItem, Per, Cost, Sell, NatRankKit, " & _
"Avg_Demand FROM [Dead Kit Components] " & _
"WHERE [KitItem] = '9W1453RP2AA' AND [KitGroup1] = 'LP';"
repHost.RecordSource = strSQL
DoCmd.OpenReport strKillKitReport, acViewPreview, , , acWindowNormal
Set repHost = Reports(strKillKitReport) ': necessary (but dumb?!)
With repHost
!txtKilledKit = strKit
!txtNoItems = strNoItems
!txtNoPieces = strNoPieces
!txtKitCost = strCost
End With

After the last bit, nothing I do in code will refresh the report, even
closing (with acSaveYes) & reopening it.

What am I not doing?

-- Al
 
Reply With Quote
 
 
 
 
Alex Dybenko
Guest
Posts: n/a
 
      21st Feb 2007
hi,
I think you need to move this code to report's open event, then you also do
not need to open it in design mode

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Allen_N" <(E-Mail Removed)> wrote in message
news:B5F88E1F-79DD-41AA-9072-(E-Mail Removed)...
>I am changing the RecordSource and unbound text boxes in a report using
>code,
> but i can't get the unbound controls to refresh automatically. I can
> manually
> switch to Design Mode and back to Preview, but closing and opening the
> report
> in code doesn't work.
>
> The only sequence that doesn't throw errors is as follows:
>
> DoCmd.OpenReport strKillKitReport, acViewDesign, , , acHidden
> Set repHost = Reports(strKillKitReport)
> strSQL = "SELECT ID, KitGroup1, KitItem, Descr, Franchise, " & _
> "Item, DescrItem, Per, Cost, Sell, NatRankKit, " & _
> "Avg_Demand FROM [Dead Kit Components] " & _
> "WHERE [KitItem] = '9W1453RP2AA' AND [KitGroup1] = 'LP';"
> repHost.RecordSource = strSQL
> DoCmd.OpenReport strKillKitReport, acViewPreview, , , acWindowNormal
> Set repHost = Reports(strKillKitReport) ': necessary (but dumb?!)
> With repHost
> !txtKilledKit = strKit
> !txtNoItems = strNoItems
> !txtNoPieces = strNoPieces
> !txtKitCost = strCost
> End With
>
> After the last bit, nothing I do in code will refresh the report, even
> closing (with acSaveYes) & reopening it.
>
> What am I not doing?
>
> -- Al


 
Reply With Quote
 
=?Utf-8?B?QWxsZW5fTg==?=
Guest
Posts: n/a
 
      22nd Feb 2007
Hi Alex,

This is no good. If I try the statement:

Me !txtKilledKit = rs![KitGroup1] & " " & rs![KitItem]

inside the Report_Open routine I get:

"You can't assign a value to this object".


 
Reply With Quote
 
Alex Dybenko
Guest
Posts: n/a
 
      22nd Feb 2007
Hi,
Ok, to set report's recordsource - you have to use open event
But for setting values to controls - you have to use Format event of section
of that control

--
Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

"Allen_N" <(E-Mail Removed)> wrote in message
news:A2815EF2-4AD8-47B0-AFEE-(E-Mail Removed)...
> Hi Alex,
>
> This is no good. If I try the statement:
>
> Me !txtKilledKit = rs![KitGroup1] & " " & rs![KitItem]
>
> inside the Report_Open routine I get:
>
> "You can't assign a value to this object".
>
>


 
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
Code to Refresh inbound data sheets, then Refresh Pivot Tables AFSSkier Microsoft Excel Programming 3 4th Sep 2009 08:59 PM
want to code REFRESH ALL, not REFRESH K90267000 via AccessMonster.com Microsoft Access Getting Started 1 28th Jan 2008 06:36 AM
report refresh pltaylor3@gmail.com Microsoft Access 0 8th Jun 2006 08:11 PM
Refresh Report's Pivot Table from code =?Utf-8?B?amVyOTk=?= Microsoft Access VBA Modules 1 22nd Nov 2005 05:31 PM
Is there a Refresh in a report ? PFMcCracken Microsoft Access 1 23rd Sep 2004 07:48 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:16 AM.