Recordsource Doesn't work after adding data

chuckcoleman

Registered User.
Local time
Today, 03:52
Joined
Aug 20, 2010
Messages
377
Hi.

Background: Reportfrm has command buttons on it to open various forms and reports. The Startupsfrm shows by town by date the number of orders that are scheduled. The Orderfrm allows work order requests to be added. The user looks at what their customer has requested as a date and on the Startupsfrm looks how many orders are already in the system for that date and town. The user then makes a decision about what date to enter into the system.

From the Reportfrm, I use a command button to open a form called Startupsfrm. The Startupsfrm form doesn't have a record source in the properties. The code below opens the Startupsfrm form and establishes the record sources, (there is also a subform in the Startupsfrm). That all works fine, and the two forms show the records that have been added before the form opens.

On another form, Orderfrm, while the Startupsfrm is still open, additional records are added based on what the customer is asking for. There is a command button on the StartupsFrm that I added the same lines below that are used to open the form from the Reportfrm.

Code:
DoCmd.OpenForm stDocName, acNormal
Forms![Customers who need startups by RequestedDD].RecordSource = "Customers who need winterized by DD-2"
Forms![Customers who need startups by RequestedDD].[Winterization Totals by DateX].Form.RecordSource = "Customers who need winterized by DD-2 Total by Date"

On the Orderfrm after a record is added and the Startupsfrm is still open, the data doesn't change, (At this point I don't expect it to change). However, when I click on the Command button with the code above, the form and subform both go blank, no records are shown.

How do I get the records to update showing the current record information?

Thanks, Chuck
 
perhaps on the Click of Command button you are referring, Close the StartupFrm first and reopen it again:
Code:
On Error Resume Next
Docmd.Close acForm, stDocName, acSaveNo

DoCmd.OpenForm stDocName, acNormal
Forms![Customers who need startups by RequestedDD].RecordSource = "Customers who need winterized by DD-2"
Forms![Customers who need startups by RequestedDD].[Winterization Totals by DateX].Form.RecordSource = "Customers who need winterized by DD-2 Total by Date"

or you can Requery the said form:

Code:
Forms![Customers who need startups by RequestedDD].Requery
Forms![Customers who need startups by RequestedDD].[Winterization Totals by DateX].Form.Requery
 
Hi arnelgp. Sorry for the delayed response; time differences and the flu. Unfortunately, I followed your first feedback to close the form, reopen it and then set the Recordsources like I do when I open the form. It results in a blank form without any records. I also tried your second suggestion and it returns a form with #Name? in the text boxes.
 

Users who are viewing this thread

Back
Top Bottom