Results 1 to 11 of 11
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Database Odd Behaviour (2003)

    If I open the Dezzo form in the attached mdb, I get a message saying Microsoft Office Access encountered an error and the application will be closed.
    How come if I put a breakpoint at the very last line of the code processed upon opening the form
    <font color=448800>Me!MilPrec.SetFocus</font color=448800> in Form_Load()
    and then just press F8 to finish the process, the Dezzo form opens normally without the error?

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

    Re: Database Odd Behaviour (2003)

    The On Current event procedure of the MG1Dez subform is executed 7 times or so when Dezzo is opened; there is a conflict somewhere in this event procedure, probably a timing conflict with the main form. The code is so complicated and so badly formatted that I cannot analyze it.

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

    Re: Database Odd Behaviour (2003)

    "Smart Indenter" available at http://www.oaltd.co.uk/Indenter/IndentPage.asp is a terrific utility that will tidy up the layout of your code.
    Regards
    John



  4. #4
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    Thank you John,
    I've tried to launch the executable for Office 2000/2002/2003 but I get the message:
    <font color=red>Corrupt installation detected</font color=red>

  5. #5
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    Thank you Hans,
    I've put some delays in the code for the Load event of the Dezzo form and the Current event of the MG1Dez subform and now the error message doesn't appear anymore but it takes an awful long time for the Dezzo form to open.

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

    Re: Database Odd Behaviour (2003)

    I'm afraid I don't understand the code in the On Current event of MG1Dez, so I don't know whether it could be simplified, and if so, how. Sorry.

  7. #7
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    Ok Hans, I'll try and explain for the MG2Dez form <img src=/S/smile.gif border=0 alt=smile width=15 height=15>:
    The subform contained in the startup form of the attached mdb opens on the day following the most recent date present in the PortDez23 table. The LETTUR1 text box in the subform should be visible for the day selected on the calendar depending on whether the value for the inLetA field in the DezG2K table is null or zero.
    I thought the following expressions in the Current event for the MG2Dez form should do the job but when the startup form opens on the October 1, 2005 date, the LETTUR1 text box remains visible notwithstanding the fact the inLetA field value for the StartDate closest or equal to the calendar date is null.
    The same happens to the MG3Dez subform.
    How would you go about conditionally hiding the LETTUR1 text boxes?

    If Not IsNull(Me.Giorno) Then
    d = DMax("StartDate", "dezg2k", "StartDate <= #" & _
    Format(Giorno, "mm/dd/yyyy") & "#")
    i = DLookup("InLetA", "dezg2k", "startDate = #" & _
    Format(d, "mm/dd/yyyy") & "#")
    If (i = 0 Or IsNull(i)) Then
    LETTUR1.Visible = False
    Me.Label131.Visible = False
    Else
    LETTUR1.Visible = True
    Me.Label131.Visible = True
    End If
    End If

  8. #8
    3 Star Lounger
    Join Date
    Jun 2001
    Location
    Salem, Oregon, USA
    Posts
    219
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    I'm probably reading this too fast, and even if I get this right it doesn't really address your questions, but I don't think I'd ever use a format in a dmax or a dlookup function -- in the "where" section of these two functions, why don't you just convert your start date to a true date (if it's not) using the cdate() function, unless your database field "StartDate" isn't a true date (in which case I'd also apply the cdate function to the table field, as well).

    I was debugging an old program written by someone else recently, and was not getting the results I expected, including it _appeared_ that some of the code just wasn't being touched. I then found the concept of "cascading events" that can cause all manner of flukey errors. The code the original programmer had placed in the "on activate" and "on current" modules (if I remember right) had calls out to so many places that these modules were getting called over and over. Once I simplified the code, some of the errors that had been bugging us simply disappeared.

    thx
    Pat

  9. #9
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    Thank you Pat,
    the StartDate field has a Date/Time data type so I guess it's a true date <img src=/S/smile.gif border=0 alt=smile width=15 height=15>.
    I've just realised though that the Current event of either subform doesn't get fired when the main form opens and so the piece of code outlined in my previous post isn't called hence the LETTUR1 text boxes aren't hidden. How can I solve it?

  10. #10
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    Giorgio,

    In the property window of the two subforms, the [Event Procedure] are missing for the On Current Event.
    Then for the code, add a else part to the first IF. Maybe wit some conditions, I don't know enough of the logic to build them:
    <pre>If Not IsNull(Me.Giorno) Then
    d = DMax("StartDate", "dezg2k", "StartDate <= #" & _
    Format(Giorno, "mm/dd/yyyy") & "#")
    i = DLookup("InLetA", "dezg2k", "startDate = #" & _
    Format(d, "mm/dd/yyyy") & "#")
    If (i = 0 Or IsNull(i)) Then
    LETTUR1.Visible = False
    Me.Label131.Visible = False
    Else
    LETTUR1.Visible = True
    Me.Label131.Visible = True
    End If
    Else
    LETTUR1.Visible = False
    Me.Label131.Visible = False

    End If</pre>

    Francois

  11. #11
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Alzano Lombardo, Italy
    Posts
    1,483
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Database Odd Behaviour (2003)

    Thank you Francois,
    works perfectly now.

Posting Permissions

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