Disabel a Control when in focus

BillyMac

Registered User.
Local time
Today, 05:20
Joined
Feb 27, 2004
Messages
24
I have a form with buttons that scroll to Next and Previous record. When you get to the last record and click the next button an Access message appears stating " You can't go to the specified record" I want to do one of to things. Either change the message that Access displays to "There are no more questions papers to view" or disable the next button when on the last record. I have tried a piece of code to disable the "Next record" control when the record is null:

If IsNull(Me.QuestionPaperID) Then
Me.NextRecordButton.Enable = False
Else: NextRecordButton.Enable = True
End If

But I get an error stating that I cannot disable a control when it has the focus. Can anyone help with this one.
 
Two things you can do.

1.. download the Image Sample Db from http://www.access-programmers.co.uk/forums/showthread.php?t=62251
It, among other things, disables the Next and Previous buttons.

2.. When the Access wizard creates a command button it adds error handling. Some times you need to trap your own errors and deal with them in defferent ways. (As you do).

There will be a line as follows:
MsgBox Err.Description

Change this to
Msgbox Err.Number

This will then tell you the error number you are up against.

2105 is the error you have.

Then replace the error handling line with something like

Select Case Err.Number

case 2105
Msgbox "There are no more questions papers to view"
Exit Sub
case else
Msgbox Err.Description
Exit Sub
End Select


HTH

Dave
 
Dave,

You're a star. I''l check this out when I get back to work.

Cheers,

Billy
 

Users who are viewing this thread

Back
Top Bottom