Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

accdb vs accde

Status
Not open for further replies.

shannonp

IS-IT--Management
Nov 13, 2001
289
NZ
Can someone tell me why my code (below) works when in accdb format but as soon as I convert to accde format I the exact same code doesn't work!

Code:
Function AddResults()
    Dim LoserScoreSlot, WinSlot, LoseSlot, LoserName As String

    LoserScoreSlot = Format(Left(Screen.ActiveForm.ActiveControl.Name, 3), "General Number")
    WinSlot = DLookup("[WinSlot]", "Allocations", "[DrawType] = '" & Trim(Left(Screen.ActiveForm.Name, 2))
    LoseSlot = DLookup("[LoseSlot]", "Allocations", "[DrawType] = '" & Trim(Left(Screen.ActiveForm.Name, 2))

    If Right(Screen.ActiveControl.Name, 1) = "a" Then
        LoserName = Left(Screen.ActiveControl.Name, 3) & "b"
    Else
        LoserName = Left(Screen.ActiveControl.Name, 3) & "a"
    End If

    If Not LoseSlot = "x" Then Screen.ActiveForm.Controls(LoseSlot) = Screen.ActiveForm.Controls(LoserName)
    Screen.ActiveForm.Controls(WinSlot) = Screen.ActiveControl
    Screen.ActiveForm.Controls("LOSER SCORE " & LoserScoreSlot) = Forms![Main Menu]![MyResult]
    Screen.ActiveForm.Recalc
End Function

When I run accde, I get the following error:

The expression on Dbl Click you entered as the event property setting produced the following errror:

You entered an expression that requires a form to be the active window.

* The expression may not result in the name of a macro, the name of a user-defined functions, or .
* There may have been an error evaluating the function, event, or macro.

This error occurs when an event has failed to run because Microsoft Office Access cannot evaluate the location of the logic for the event. For example, if the OnOpen property of a form is set to =, this error occurs because Access expects a macro or event name to run when the event is fired.


I could probably alter the code to make it work but that still doesn't answer my question as to why it works with accdb file but not accde??

[yinyang]
Shann
 
A few of things, here:

Generally speaking, things that don't work in mde/accde files don't work because, in one way or another, they are attempting to make Design Changes to the app, which is not allowed. Sorry, but your code is far too esoteric for me to simply look at, from my standpoint, and immediately intuit your intentions, here.

Secondly, the Access Gnomes are not known for being accurate about the origin of errors reported, nor about the line of code they blame for the error! They frequently, in point of fact, highlight the next line of code after the errant line, instead!

The original error message seems to indicate that the error occurred when a Control's Double-Click event fired, but there is no such event listed in the posted code. Perhaps the AddResults Function was called from such an event, and the actual error resides in that code, rather than the code posted here.

Finally, do you have other code that is working, after the conversion? At times, after creating an accde file, it is placed in a different Folder from the one it resided in when it was an accdb file, and the new location wasn't declared as 'Trusted,' thus blocking all code from working!

The Missinglinq

Richmond, Virginia

The Devil's in the Details!
 
I agree the code is a bit "esoteric". All code should have error handling. You could add some debugging functionality such as MsgBox or other to determine which line is causing the error.

Duane
Hook'D on Access
MS Access MVP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top