Can't refresh report in code.

G

Guest

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
 
G

Guest

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".
 

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

Similar Threads


Top