Weird: Code works in MDB but not in MDE

  • Thread starter Thread starter mscertified
  • Start date Start date
M

mscertified

I have an MDB that works flawlessly but when I create an MDE from it gives
the following error:

"The expression After Update you entered as the event property setting
produced the following error: You can't assign a value to this object.

This is 'after update' event of combo box. Any clues??? I was getting this
in the MDB but commented the offending statements out the recompiled. How do
I debug an MDE?
 
Was the MDB compiled before creating the MDE? Was the MDE created using the
same version of Access that the MDB was created in?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
yes to both questions.

Jeff Boyce said:
Was the MDB compiled before creating the MDE? Was the MDE created using the
same version of Access that the MDB was created in?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
How about posting the code in the After Update event and point out the line
where the error occurs?
 
OK, I have determined the following:-
With no OnError trap in the code the MDB does not generate an error but the
MDE does.
If I put OnError trap in MDB, an error is generated

Code (there are combo boxes in a continuous form subform):

Private Sub Defect_AfterUpdate()
On Error GoTo ER
Me!CorrectiveActions.Value = Null
Me!DefectID = Me!Defect.Column(0) <==== Fails
Exit Sub
ER:
MsgBox Err.Description, , "Defect_AfterUpdate"
End Sub

Private Sub CorrectiveActions_AfterUpdate()
On Error GoTo ER
Me!CAID = Me!CorrectiveActions.Column(0) <==== Fails
Exit Sub
ER:
MsgBox Err.Description, , "CorrectiveActions_AfterUpdate"
End Sub
 
Not sure whether this is related to your problem, but that's not really
proper error handling.

Once an error's raised, you need to clear it. Typically, this is done using:

Private Sub Defect_AfterUpdate()
On Error GoTo ER
Me!CorrectiveActions.Value = Null
Me!DefectID = Me!Defect.Column(0)
Done:
Exit Sub
ER:
MsgBox Err.Description, , "Defect_AfterUpdate"
Resume Done
End Sub

although I supposed you could use

Private Sub Defect_AfterUpdate()
On Error GoTo ER
Me!CorrectiveActions.Value = Null
Me!DefectID = Me!Defect.Column(0) <==== Fails
Exit Sub
ER:
MsgBox Err.Description, , "Defect_AfterUpdate"
Err.Clear
End Sub
 
Thanks for the tip. I've been doing it that way for years and its never to my
knowledge caused a problem.
 
Back
Top