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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Odd error "The function you entered cannot be used in this expression"

Status
Not open for further replies.

scorpio1769

Programmer
Apr 11, 2001
38
US
I've got a macro on an mde. database that has been working for years. all of the sudden, my user reports to me that upon execution of the macro, he gets the error message

"The function you entered cannot be used in this expression.
*You may have used a DoEvents,....."

This macro fires on the after update event of a combo box and simply creates a purchase order number according to the following.

[Forms]![Frm_InventoryOrderMaster]![DishOrDirect] & "-" & Format([Forms]![Frm_InventoryOrderMaster]![OrderMade],"mmddyy") & "/" & [Forms]![Frm_InventoryOrderMaster]![Area]

As I said, this has been working for ages and all of the sudden the user gets the error.

Secondly, this is not the first time I've seen this error before. A different user had the same error although she was not using the same function.

I've read about references and whatnot but they're using an mde.

Any help would be appreciated,

scorpio1769

 
I would wonder - did they recently get an upgrade to Access? Perhaps they went from 2000 to 2003 or something like that?

Just an idea - and along the lines of the references thought, so it might be way off.

To troubleshoot - perhaps take the macro and turn it into code. Then you can add error handling and find out the problem and look it up online.

If you aren't sure about it in vba, just right-click the macro and choose save as module. Then copy and paste the code you get into the after update event of the combo instead of using the macro.

For errorhandling I like to do something like the following:

Private Sub control_AfterUpdate()
On error goto Errorhandler

all my code
Exit Sub
ErrorHandler:
MsgBox Err.Description & " " & Err.Number
End Sub

then instead of the not so helpful message the macro gives you, your used will have an error description and number for you, and usually you can get more info online using that number.
 
Belovedcej,

Thanks for the tip. I converted to VBA and added the err.number as you said and the error magically went away. if my user does get the error again, perhaps I'll have some more information to trouble shoot.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top