Getting Rid of #Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • David Davis
    New Member
    • Mar 2008
    • 41

    Getting Rid of #Error

    Hello,

    I need help on getting rid of #Error in my fields on a form when no data exist. I was using the below formula:

    ="" & [System]

    and when #Error showed I switched over to

    =IIf(IsNull([System])," ",[System])

    and that came up with the same results. If data exist it works fine but when data is not there I want it to be blank or say "No data exist".

    What formula can I use in the control source to fix this. Any assistance would be most appreciative.

    Thanks
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    What exactly is [System]? What Datatype?

    Welcome to TheScripts!

    Linq ;0)>

    Comment

    • janders468
      Recognized Expert New Member
      • Mar 2008
      • 112

      #3
      I'm trying to duplicate this error to see if I can fix it, what data type is your [System] Column?

      Comment

      • David Davis
        New Member
        • Mar 2008
        • 41

        #4
        Originally posted by janders468
        I'm trying to duplicate this error to see if I can fix it, what data type is your [System] Column?
        Sorry about the slow response but two are of text and one is Date/Time.

        It looks like this

        ="of " & [StudentCompany]

        ="" & [System]

        =" on " & [GraduationDate]

        Let me know what you come up with.

        Thanks

        Comment

        • David Davis
          New Member
          • Mar 2008
          • 41

          #5
          Originally posted by missinglinq
          What exactly is [System]? What Datatype?

          Welcome to TheScripts!

          Linq ;0)>
          I'm sorry Linq, but System is one of the fields from table1 used on the form and DataType is text.

          Thanks for the fast response sorry couldnt say the same but step out a bit, didnt think anyone would respond back so quick.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32661

            #6
            David,

            I've tried various approaches but was unable to duplicate your problem in any of them I'm afraid.

            It appears there's some quite fundamental information that you haven't included in the question. I can't tell you what it may be, but this isn't standard behaviour in a form to report #Error simply because a field has no data.

            Comment

            • David Davis
              New Member
              • Mar 2008
              • 41

              #7
              Originally posted by NeoPa
              David,

              I've tried various approaches but was unable to duplicate your problem in any of them I'm afraid.

              It appears there's some quite fundamental information that you haven't included in the question. I can't tell you what it may be, but this isn't standard behaviour in a form to report #Error simply because a field has no data.

              NeoPa,

              I miss quoted before in saying it was a form, in fact it is a report. I am missing something but cant figure it out.

              David

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32661

                #8
                I think the matching answer is :
                Code:
                =IIf(IsError([System]),'',[System])

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32661

                  #9
                  Should the question rather be though :
                  How do I stop a report from running if there are no matching records?

                  If so, the answer is that there is an On No Data event.
                  Code:
                  Private Sub Report_NoData(Cancel As Integer)
                  
                  End Sub
                  This allows code to run informing the operator of the situation as well as allowing the report to be cancelled entirely (Set Cancel to True before exiting procedure).

                  Comment

                  • David Davis
                    New Member
                    • Mar 2008
                    • 41

                    #10
                    Originally posted by NeoPa
                    Should the question rather be though :
                    How do I stop a report from running if there are no matching records?

                    If so, the answer is that there is an On No Data event.
                    Code:
                    Private Sub Report_NoData(Cancel As Integer)
                    
                    End Sub
                    This allows code to run informing the operator of the situation as well as allowing the report to be cancelled entirely (Set Cancel to True before exiting procedure).
                    Thanks NeoPa,

                    Good solution but how do you set it to true.

                    David

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32661

                      #11
                      At its simplest :
                      Code:
                      Private Sub Report_NoData(Cancel As Integer)
                        Cancel = True
                      End Sub

                      Comment

                      • Scott Price
                        Recognized Expert Top Contributor
                        • Jul 2007
                        • 1384

                        #12
                        Have a look at Avoid #Error in Form/Report with no data on Allen Browne's website.

                        Regards,
                        Scott

                        Comment

                        • David Davis
                          New Member
                          • Mar 2008
                          • 41

                          #13
                          Originally posted by Scott Price
                          Have a look at Avoid #Error in Form/Report with no data on Allen Browne's website.

                          Regards,
                          Scott

                          Thanks for the information.

                          David

                          Comment

                          • David Davis
                            New Member
                            • Mar 2008
                            • 41

                            #14
                            Originally posted by NeoPa
                            At its simplest :
                            Code:
                            Private Sub Report_NoData(Cancel As Integer)
                              Cancel = True
                            End Sub
                            NeoPa,

                            Thanks, that worked perfectly I have just one more question. How can you make Microsoft Access close the same time the database closes.

                            David

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32661

                              #15
                              There's no really direct way, but if you cause an invisible form to open when you open the database (Tools / Startup...) then you can leave it running in the background while the database is open.

                              In the Form_Close() event procedure you can then call a close of Access itself :
                              Code:
                              Private Sub Form_Close()
                                Call Application.Quit
                              End Sub

                              Comment

                              Working...