Advertisement

09.07.2007 at 05:19AM PDT, ID: 22813119
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4

Access Form  Before Update Event on button click to change filter on displayed records. Error Handling.

Asked by Louverril in Access Forms, Microsoft Access Database

Tags: , , ,

I have a form with a subform.

On the  main form (frmcases) there are two buttons. One filters the records in the subform (frmCare_Options) to show only those in the "Past Requirements" section. The other shows only those in the "Future Requirements" section.

When the  main form is first opened it shows the  "Past Requirements"  records.

The checking for any errors when entering a Past Requirement or a Future Requirement (obviously) record on the subform is on the Before Update event of the form.

EVERYTHING WORKS FINE UNLESS THERE ARE NO  PAST REQUIREMENTS RECORDS WHEN THE FORMS FIRST OPEN.

My problem happens when there are no Past requirement records, and the form has just been opened, but you decide you want to enter a Future Requirements record and  click the "Future Requirements" button. If there was a Past requirements record there and  it was in error the error message comes up  fine , you correct it and then clcik the Future requirements button again.

But if there wasn't a Past Requirements record (just a blank form with some default values showing)  when you click the Future Requirements button, the Before Update Event fires but the the  onclick event on the Future Requirements button also starts and  won't cancel (or I can't cancel it). So what happens is the before update error on the Past Requirements record comes up with the correct message etc. but rather than go back to showing the record that was in error to let you re-enter the data or Esc,  the system continues to process the commands for the Future Requirements  button event and gets into a bit of a pickle (running the after update events again etc...).

Just to reiterate this only happens when there are no past requirements records and ONLY when the form has just been loaded. If you go back to the main record with no past requirements later and click the future requirements the process works fine - tells you all the required fields haven't been entered and you can correct that or esc before pressing teh Future Requirements button again to carry on..

SO : I want the Past requirements button event to be cancelled if the before update event on the  "Past requirements" record picked up an error - like what happens in all circumsatance except on inital load when there a re no Past Requirements.  or ignore the Past Requirments untouched blank (apart from defaults) record.

SEE RELEVANT CODE BELOW.

Thanks Lou



CODE FOR BEFORE UPDATE EVENT
Private Sub Form_BeforeUpdate(Cancel As Integer)
' make sure a care option description is entered

On Error GoTo Error
     
    If Len(Me!CO_Desc.Value & vbNullString) = 0 Then
         Call CCEntryReq
         Cancel = True
    End If
    Exit Sub
   
Error:
    MsgBox Err.Number & " " & Err.Description
    Resume Next
End Sub

Public Function CCEntryReq()

MsgBox "All mandatory fields (those marked *) do not have a value entered. Please make an entry in all these fields or press Esc to abandon this record.", 48, _
        "Care Report Costing System"
       
End Function

CODE FOR FUTURE REQUIREMENT BUTTON ON CLICK EVENT
Private Sub btnFuture_Click()
'Highlights the Future Requirements button and filters the records to those equal to section 1
 
    On Error GoTo Error
   
    Me.Form![frmCare_Options].SetFocus
    Me.[frmCare_Options].Form.Visible = True
    Me.[frmCase_Equipment].Form.Visible = False
   
    CCHighlightSection Me.btnFuture
    CCInactiveSection Me.btnPastReq
    CCInactiveSection Me.btnEq
    CCInactiveSection Me.btnReport
   
    Me.Form![frmCare_Options].Form.RecordSource = "qryCOFuture_Section"
    lngSection = 2 ' so section can be set on a care option new record later
    If Me.[frmCare_Options].Form.NewRecord Then
     frmCare_Options.Form!C_Section = lngSection
    End If
 
ExitSub:
    Exit Sub

Error:
    MsgBox Err.Number & " " & Err.Description
    Resume Next

End Sub


Start Free Trial
 
Loading Advertisement...
 
[+][-]09.07.2007 at 07:35AM PDT, ID: 19848041

View this solution now by starting your 14-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Access Forms, Microsoft Access Database
Tags: access, form, update, button
Sign Up Now!
Solution Provided By: thenelson
Participating Experts: 1
Solution Grade: B
 
 
[+][-]09.07.2007 at 08:02AM PDT, ID: 19848276

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.08.2007 at 05:30AM PDT, ID: 19853174

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 14-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-43 / EE_QW_2_20070628