No current record?

M

Mark A. Sam

Hello,

In a textbox of a continuous subform I have this code in the BeforeUpdate
event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which says,

"No current record." w/o quotes and no err number. The problem is the undo
method. I have tried, DoCmd.RunCommand acCmdUndo and [EmailAdddress].Undo
with the same result. This is an A2002 mdb database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
 
M

Mark A. Sam

Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True is
before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

strive4peace said:
put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Hello,

In a textbox of a continuous subform I have this code in the BeforeUpdate
event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this
form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which
says,

"No current record." w/o quotes and no err number. The problem is the
undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
 
S

strive4peace

Hi Mark,

what code do you have on the form Current event?

also, put an error handler in ... the error may not be in this procedure ...


Which statement is causing the problem?

Add an error handler to your code

put this at the top of your program, right after the procedure
declaration (skip a line first for better readability)

then come the statements of your procedure

then the lines at the bottom -- be sure to replace ProcedureName


'~~~~~~~~~ Error handler code ~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'statements

Proc_Exit:
On Error Resume Next
'close and release object variables
Exit function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~`

where
ProcedureName is the name of your procedure so you can identify what
code the problem is in when you see the error

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a procedure.


if you get an error, press CTRL-BREAK when the message box pops up,
Enter to dismiss the dialog box

this takes you into the code

right-click on the [color:blue]Resume[/QUOTE] statement
from the shortcut menu, choose --> Set Next Statement

then press F8 to resume with the statement that caused the problem
pressing F8 executes one statement at a time

press F5 to continue execution automatically


~~~
While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the
code and Resume goes back to the offending line. When code Stops, press
F8 to execute one statement at a time.






Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True is
before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

strive4peace said:
put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Hello,

In a textbox of a continuous subform I have this code in the BeforeUpdate
event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this
form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which
says,

"No current record." w/o quotes and no err number. The problem is the
undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
 
M

Mark A. Sam

Crystal,

I 'm not sure if you noticed that I posted my procedure in my first message
and it contained an error handler. I'm an experienced developer. This gave
me no error number and resume next didn't eliminate the problem. I've come
to the conclusion that the module is likely corrupted. I'll just rebuild
the form. I have another app on a remote server in another version of
Access which bombed out on me also, and I just updated a backup and its
fine. This will be too.

Thanks for your input.

God Bless,

Mark


strive4peace said:
Hi Mark,

what code do you have on the form Current event?

also, put an error handler in ... the error may not be in this procedure
...


Which statement is causing the problem?

Add an error handler to your code

put this at the top of your program, right after the procedure declaration
(skip a line first for better readability)

then come the statements of your procedure

then the lines at the bottom -- be sure to replace ProcedureName


'~~~~~~~~~ Error handler code ~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'statements

Proc_Exit:
On Error Resume Next
'close and release object variables
Exit function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~`

where
ProcedureName is the name of your procedure so you can identify what code
the problem is in when you see the error

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a procedure.


if you get an error, press CTRL-BREAK when the message box pops up,
Enter to dismiss the dialog box

this takes you into the code

right-click on the [color:blue]Resume
statement
from the shortcut menu, choose --> Set Next Statement

then press F8 to resume with the statement that caused the problem
pressing F8 executes one statement at a time

press F5 to continue execution automatically


~~~
While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the code
and Resume goes back to the offending line. When code Stops, press F8 to
execute one statement at a time.






Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True is
before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

strive4peace said:
put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello,

In a textbox of a continuous subform I have this code in the
BeforeUpdate event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this
form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which
says,

"No current record." w/o quotes and no err number. The problem is the
undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
[/QUOTE]
 
S

strive4peace

hi Mark,

with all due respect, why do you use
Resume Next
?

all your handler does is SKIP the line with the problem and move on to
the next ... so you cannot tell what line is causing the problem -- look
at the error handler code I gave you -- and read how to set it on the
line with the problem in the comments I put after the code

whenever you get an error message, you need to know WHICH statement
caused it...

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Crystal,

I 'm not sure if you noticed that I posted my procedure in my first message
and it contained an error handler. I'm an experienced developer. This gave
me no error number and resume next didn't eliminate the problem. I've come
to the conclusion that the module is likely corrupted. I'll just rebuild
the form. I have another app on a remote server in another version of
Access which bombed out on me also, and I just updated a backup and its
fine. This will be too.

Thanks for your input.

God Bless,

Mark


strive4peace said:
Hi Mark,

what code do you have on the form Current event?

also, put an error handler in ... the error may not be in this procedure
...


Which statement is causing the problem?

Add an error handler to your code

put this at the top of your program, right after the procedure declaration
(skip a line first for better readability)

then come the statements of your procedure

then the lines at the bottom -- be sure to replace ProcedureName


'~~~~~~~~~ Error handler code ~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'statements

Proc_Exit:
On Error Resume Next
'close and release object variables
Exit function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~`

where
ProcedureName is the name of your procedure so you can identify what code
the problem is in when you see the error

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a procedure.


if you get an error, press CTRL-BREAK when the message box pops up,
Enter to dismiss the dialog box

this takes you into the code

right-click on the [color:blue]Resume
statement
from the shortcut menu, choose --> Set Next Statement

then press F8 to resume with the statement that caused the problem
pressing F8 executes one statement at a time

press F5 to continue execution automatically


~~~
While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the code
and Resume goes back to the offending line. When code Stops, press F8 to
execute one statement at a time.






Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True is
before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello,

In a textbox of a continuous subform I have this code in the
BeforeUpdate event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this
form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which
says,

"No current record." w/o quotes and no err number. The problem is the
undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
[/QUOTE]
 
M

Mark A. Sam

Crystal,
I used Resume Next, becuase there was no err number to trap, and I wanted to
suppress the message. The procedure works fine, other than the message
coming up for no apparent reason. You don't need error handling in every
situation. I don't use it for short, routine procedures unless there is a
problem to discern.

God Bless,

Mark


strive4peace said:
hi Mark,

with all due respect, why do you use
Resume Next
?

all your handler does is SKIP the line with the problem and move on to the
next ... so you cannot tell what line is causing the problem -- look at
the error handler code I gave you -- and read how to set it on the line
with the problem in the comments I put after the code

whenever you get an error message, you need to know WHICH statement caused
it...

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Crystal,

I 'm not sure if you noticed that I posted my procedure in my first
message and it contained an error handler. I'm an experienced developer.
This gave me no error number and resume next didn't eliminate the
problem. I've come to the conclusion that the module is likely
corrupted. I'll just rebuild the form. I have another app on a remote
server in another version of Access which bombed out on me also, and I
just updated a backup and its fine. This will be too.

Thanks for your input.

God Bless,

Mark


strive4peace said:
Hi Mark,

what code do you have on the form Current event?

also, put an error handler in ... the error may not be in this procedure
...


Which statement is causing the problem?

Add an error handler to your code

put this at the top of your program, right after the procedure
declaration (skip a line first for better readability)

then come the statements of your procedure

then the lines at the bottom -- be sure to replace ProcedureName


'~~~~~~~~~ Error handler code ~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'statements

Proc_Exit:
On Error Resume Next
'close and release object variables
Exit function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~`

where
ProcedureName is the name of your procedure so you can identify what
code the problem is in when you see the error

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a
procedure.


if you get an error, press CTRL-BREAK when the message box pops up,
Enter to dismiss the dialog box

this takes you into the code

right-click on the [color:blue]Resume
statement
from the shortcut menu, choose --> Set Next Statement

then press F8 to resume with the statement that caused the problem
pressing F8 executes one statement at a time

press F5 to continue execution automatically


~~~
While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the
code and Resume goes back to the offending line. When code Stops, press
F8 to execute one statement at a time.






Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True is
before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello,

In a textbox of a continuous subform I have this code in the
BeforeUpdate event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this
form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which
says,

"No current record." w/o quotes and no err number. The problem is
the undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
[/QUOTE]
 
S

strive4peace

Hi Mark,

sometimes chasing down these errors can be intense! When I get one that
I do not know where it comes from, I start putting error handlers
everywhere. Like you, I normally do not put them in code I think would
not have a problem.

another option you may want to explore is to set the default to
Break on All Errors

the 'No current record' error message indicates that, somewhere, you
have a reference to a record or control where there is none -- check
RowSource of a combos and listboxes too

did you compile the code?


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Crystal,
I used Resume Next, becuase there was no err number to trap, and I wanted to
suppress the message. The procedure works fine, other than the message
coming up for no apparent reason. You don't need error handling in every
situation. I don't use it for short, routine procedures unless there is a
problem to discern.

God Bless,

Mark


strive4peace said:
hi Mark,

with all due respect, why do you use
Resume Next
?

all your handler does is SKIP the line with the problem and move on to the
next ... so you cannot tell what line is causing the problem -- look at
the error handler code I gave you -- and read how to set it on the line
with the problem in the comments I put after the code

whenever you get an error message, you need to know WHICH statement caused
it...

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Crystal,

I 'm not sure if you noticed that I posted my procedure in my first
message and it contained an error handler. I'm an experienced developer.
This gave me no error number and resume next didn't eliminate the
problem. I've come to the conclusion that the module is likely
corrupted. I'll just rebuild the form. I have another app on a remote
server in another version of Access which bombed out on me also, and I
just updated a backup and its fine. This will be too.

Thanks for your input.

God Bless,

Mark


Hi Mark,

what code do you have on the form Current event?

also, put an error handler in ... the error may not be in this procedure
...


Which statement is causing the problem?

Add an error handler to your code

put this at the top of your program, right after the procedure
declaration (skip a line first for better readability)

then come the statements of your procedure

then the lines at the bottom -- be sure to replace ProcedureName


'~~~~~~~~~ Error handler code ~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'statements

Proc_Exit:
On Error Resume Next
'close and release object variables
Exit function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~`

where
ProcedureName is the name of your procedure so you can identify what
code the problem is in when you see the error

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use the
same ones all the time -- they only have to be unique within a
procedure.


if you get an error, press CTRL-BREAK when the message box pops up,
Enter to dismiss the dialog box

this takes you into the code

right-click on the [color:blue]Resume
statement
from the shortcut menu, choose --> Set Next Statement

then press F8 to resume with the statement that caused the problem
pressing F8 executes one statement at a time

press F5 to continue execution automatically


~~~
While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the
code and Resume goes back to the offending line. When code Stops, press
F8 to execute one statement at a time.






Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True is
before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello,

In a textbox of a continuous subform I have this code in the
BeforeUpdate event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from this
form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box which
says,

"No current record." w/o quotes and no err number. The problem is
the undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
[/QUOTE]
 
M

Mark A. Sam

Crystal,

I know this is corruption. I broke the coke on the first line, and when I
stop the code (still on the first line), the message popped up. Trying to
debug would be a waste of time. I really shouldn't have posted this, but I
tend to forget about corruption.

God Bless,

Mark


strive4peace said:
Hi Mark,

sometimes chasing down these errors can be intense! When I get one that I
do not know where it comes from, I start putting error handlers
everywhere. Like you, I normally do not put them in code I think would
not have a problem.

another option you may want to explore is to set the default to
Break on All Errors

the 'No current record' error message indicates that, somewhere, you have
a reference to a record or control where there is none -- check RowSource
of a combos and listboxes too

did you compile the code?


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*


Crystal,
I used Resume Next, becuase there was no err number to trap, and I wanted
to suppress the message. The procedure works fine, other than the
message coming up for no apparent reason. You don't need error handling
in every situation. I don't use it for short, routine procedures unless
there is a problem to discern.

God Bless,

Mark


strive4peace said:
hi Mark,

with all due respect, why do you use
Resume Next
?

all your handler does is SKIP the line with the problem and move on to
the next ... so you cannot tell what line is causing the problem -- look
at the error handler code I gave you -- and read how to set it on the
line with the problem in the comments I put after the code

whenever you get an error message, you need to know WHICH statement
caused it...

Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Crystal,

I 'm not sure if you noticed that I posted my procedure in my first
message and it contained an error handler. I'm an experienced
developer. This gave me no error number and resume next didn't
eliminate the problem. I've come to the conclusion that the module is
likely corrupted. I'll just rebuild the form. I have another app on a
remote server in another version of Access which bombed out on me also,
and I just updated a backup and its fine. This will be too.

Thanks for your input.

God Bless,

Mark


Hi Mark,

what code do you have on the form Current event?

also, put an error handler in ... the error may not be in this
procedure ...


Which statement is causing the problem?

Add an error handler to your code

put this at the top of your program, right after the procedure
declaration (skip a line first for better readability)

then come the statements of your procedure

then the lines at the bottom -- be sure to replace ProcedureName


'~~~~~~~~~ Error handler code ~~~~~~~~~

'set up Error Handler
On Error GoTo Proc_Err

'statements

Proc_Exit:
On Error Resume Next
'close and release object variables
Exit function

Proc_Err:
MsgBox Err.Description, , _
"ERROR " & Err.Number _
& " ProcedureName"

Resume Proc_Exit

'if you want to single-step code to find error, CTRL-Break at
MsgBox
'then set this to be the next statement
Resume
'~~~~~~~~~~~~~~~~~~~~~~`

where
ProcedureName is the name of your procedure so you can identify what
code the problem is in when you see the error

The line labels do not matter (Proc_Exit:, Proc_Err:), I like to use
the same ones all the time -- they only have to be unique within a
procedure.


if you get an error, press CTRL-BREAK when the message box pops up,
Enter to dismiss the dialog box

this takes you into the code

right-click on the [color:blue]Resume
statement
from the shortcut menu, choose --> Set Next Statement

then press F8 to resume with the statement that caused the problem
pressing F8 executes one statement at a time

press F5 to continue execution automatically


~~~
While I am developing, I like to make the error handler go to the line
that caused the problem so I can see where it is. Stop will stop the
code and Resume goes back to the offending line. When code Stops,
press F8 to execute one statement at a time.






Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello Crystal,

What you have stated is how my code is in my posting, Cancel = True
is before Me.Undo.

I have already tried,

[EmailAdddress].Undo as well as

DoCmd.RunCommand acCmdUndo

I also decompiled my DB.

Thanks for your response and God Bless,

Mark

put this statement:

Cancel = true

before

Me.Undo

if you are only wanting to undo the email address control, use:

me.EmailAdddress.undo


Warm Regards,
Crystal

Access Basics
8-part free tutorial that covers essentials in Access
http://www.accessmvp.com/Strive4Peace/Index.htm

*
:) have an awesome day :)
*



Mark A. Sam wrote:
Hello,

In a textbox of a continuous subform I have this code in the
BeforeUpdate event:

Private Sub EmailAdddress_BeforeUpdate(Cancel As Integer)
On Error GoTo errSec

If GetUserLevel() <> "admin" Then
Cancel = True
MsgBox "Only an Administrator can change email addresses from
this form!"
Me.Undo
End If

exitSec:
Exit Sub

errSec:
MsgBox "Error " & Err & ": " & Err.Description
Resume Next

End Sub


When this runs and the user is not "admin" I get a message box
which says,

"No current record." w/o quotes and no err number. The problem is
the undo method. I have tried, DoCmd.RunCommand acCmdUndo and
[EmailAdddress].Undo with the same result. This is an A2002 mdb
database, opened with A2007.

Thanks for any help and God Bless,

Mark A. Sam
[/QUOTE]
 
M

Mark A. Sam

This problem cleared when I opened it in A2003 on another machine, and made
an mde file. I was using A2007 on my machine, becuase Office 2007 isn't
Office 2002 friendly and blew it away. I had to changed libraries from
Outlook 12.0 to Outlook 11.0. I don't know if this was associated with the
issue, but mentioning it.

This is a problem were there was no err number (3021), so I couldn't trap
it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top