Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Oct 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    A warning (Access 2000)

    In the Format event of my report i have a warning that gives a message in case the number of any student does not correspond to the number of his or her banks.Each student has several banks.However usually i have more than one discrepancies and i get the result as a warning message for each one.I want to get only one warning message,if there is at least one discrepancy.What command can i give for that purpose ? Further, can i have a control on my form, that also gives a message in case something is wrong with the data of my report ?
    I use the following condition:
    If Me![Students] <> Me!Banks Then
    result = MsgBox("Something is wrong with the balance of the class.", vbOKOnly, "Warning")

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: A warning (Access 2000)

    Welcome to Woody's Lounge!

    To be able to answer your question, we'd need to know more about the stucture of your database. Could you post a stripped down copy of your database? See <post#=401925>post 401925</post#> for instructions.

  3. #3
    New Lounger
    Join Date
    Oct 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: A warning (Access 2000)

    Thanks for the reply.It took me a long time to demolish the database by stripping it.It was difficult but i have done something that may give an idea what is wrong with the report.Actually the fields students and banks are not in a table but on a query,but i have made it simpler to be more easier.So in a nutshell: the number of the students should be equal to the number of the banks.If something is wrong, then " the bell shall ring".In my example what is wrong is : position 2 and position 5.The problem is that the message does appear not only once, but several times depending on the number of the wrong positions.How can i make it appear only once ,to say that there is some error, but not to specify whch one ? Also,is it possible that my control on the form turns to red if something is wrong with the report ? Am i aksing for the impossible, since the form is unbound ?

    Shokarov

  4. #4
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: A warning (Access 2000)

    The detail_format event fires for each record, so you get mutliple message boxes.

    Instead declare a boolean (yes/no) variable , set it to false when the report opens.

    In the detail-format event set it to true if the students <. blanks.

    In the report footer, check whether the variable is true, and if it is show the message box.

    Option Compare Database
    Option Explicit
    Dim blsomethingwrong As Boolean
    ********************
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Dim result As String
    If Me![Students] <> Me!Banks Then
    blsomethingwrong = True
    End If
    End Sub
    ******************
    Private Sub Report_Open(Cancel As Integer)
    blsomethingwrong = False
    End Sub
    *******************
    Private Sub ReportFooter_Format(Cancel As Integer, FormatCount As Integer)
    If blsomethingwrong = True Then
    MsgBox "Something is wrong with the balance of the class.", vbOKOnly, "Warning"

    End If
    End Sub
    Regards
    John



  5. #5
    New Lounger
    Join Date
    Oct 2005
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: A warning (Access 2000)

    Wonderful.I have copied ll your reccomendations into my report and now it gives only one message.You have not only corrrected my mistake but also explained to me why it happened.I am very grateful for that

    Shokarov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •