|
From: JaneP on 1 Jul 2008 10:10 Hi, I've created a form [Select Name] which ask for a name to be select from a combo box to run the query [Overdue & Due Actions] which then in turns runs the report but when it runs the query, which I see has run correctly, it then asks for the name again but this time I need to type it in. If I don't enter anything in the 2nd time the report is blank. The parameters form has an 'OK' button with the following coding for On Click Private Sub Cancel_Click() DoCmd.Close 'Close Form End Sub Private Sub OK_Click() Me.Visible = False DoCmd.OpenQuery "Overdue & Due Actions", acViewNormal, acEdit DoCmd.Close acForm, "Select Name" End Sub The query refers to [Forms]![Select Name]![Name] under the Responsibility field & if I take this out the report doesn't run properly. The report's coding is Private Sub Report_Close() DoCmd.Close acForm, "Select Name" DoCmd.Close acQuery, "Overdue & Due Actions" End Sub Private Sub Report_Open(Cancel As Integer) DoCmd.OpenForm "Select Name", , , , , acDialog End Sub I've looked at the other questions in the forum & can't seem to find an answer that works for me. I'm not VBA person so I'm picking up the coding from different help sources in Microsoft in particular "Using parameters with queries & reports" but I am now struggling Thanks
From: Marshall Barton on 1 Jul 2008 10:25 JaneP wrote: >I've created a form [Select Name] which ask for a name to be select from a >combo box to run the query [Overdue & Due Actions] which then in turns runs >the report but when it runs the query, which I see has run correctly, it then >asks for the name again but this time I need to type it in. If I don't enter >anything in the 2nd time the report is blank. >The parameters form has an 'OK' button with the following coding for On Click >Private Sub Cancel_Click() > DoCmd.Close 'Close Form >End Sub >Private Sub OK_Click() > Me.Visible = False > DoCmd.OpenQuery "Overdue & Due Actions", acViewNormal, acEdit > DoCmd.Close acForm, "Select Name" >End Sub > >The query refers to [Forms]![Select Name]![Name] under the Responsibility >field & if I take this out the report doesn't run properly. > >The report's coding is >Private Sub Report_Close() > DoCmd.Close acForm, "Select Name" > DoCmd.Close acQuery, "Overdue & Due Actions" >End Sub > >Private Sub Report_Open(Cancel As Integer) >DoCmd.OpenForm "Select Name", , , , , acDialog >End Sub While I would open the form in normal mode before opening the report, I think you code your code will work if you remove the Close line in the OK event. -- Marsh MVP [MS Access]
From: JaneP on 1 Jul 2008 10:42 Thanks, Marshall it worked. I've been going round the bend with this so this has made my day! "Marshall Barton" wrote: > JaneP wrote: > >I've created a form [Select Name] which ask for a name to be select from a > >combo box to run the query [Overdue & Due Actions] which then in turns runs > >the report but when it runs the query, which I see has run correctly, it then > >asks for the name again but this time I need to type it in. If I don't enter > >anything in the 2nd time the report is blank. > >The parameters form has an 'OK' button with the following coding for On Click > >Private Sub Cancel_Click() > > DoCmd.Close 'Close Form > >End Sub > >Private Sub OK_Click() > > Me.Visible = False > > DoCmd.OpenQuery "Overdue & Due Actions", acViewNormal, acEdit > > DoCmd.Close acForm, "Select Name" > >End Sub > > > >The query refers to [Forms]![Select Name]![Name] under the Responsibility > >field & if I take this out the report doesn't run properly. > > > >The report's coding is > >Private Sub Report_Close() > > DoCmd.Close acForm, "Select Name" > > DoCmd.Close acQuery, "Overdue & Due Actions" > >End Sub > > > >Private Sub Report_Open(Cancel As Integer) > >DoCmd.OpenForm "Select Name", , , , , acDialog > >End Sub > > > While I would open the form in normal mode before opening > the report, I think you code your code will work if you > remove the Close line in the OK event. > > -- > Marsh > MVP [MS Access] >
|
Pages: 1 Prev: Chart based on data from report Next: Not display repeated values in a field |