Re: Disable Command Button After Click
- From: ridgerunner <ridgerunner@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 8 May 2008 11:18:01 -0700
I moved the 'Me.AddQsts.Enable = FALSE' to the 'on enter' property for the
AddQsts field and that works; the button is greyed out and unavailable. I
can add the score to the first record but only after I use my cursor to move
down to the second record and back up to the first record. Can you please
tell me how to fix this?
Many thanks!
"ridgerunner" wrote:
Is this going to cause a problem?.
IF YOU HAD A DIRTY NEW RECORD THEN IT IS NO LONGER A NEW RECORD BECAUSE OF
THE CODE ABOVE.
The code below:
Me.OtherControlName.SetFocus '-- Use YOUR OtherControlName of course.
Me.AddQsts.Enable = FALSE
is causing an error message "Run-time error '2164' " " You can't disable a
control while it has the focus."
I set the focus to my other control name and the cursor "lands" there but I
cannot add the score.
Thanks.
"ruralguy via AccessMonster.com" wrote:
Notes in line:
ridgerunner wrote:
Thanks so much for your help. Here is the code.
Private Sub AddQsts_Click()
'save record if changes have been made
If Me.Dirty Then Me.Dirty = False
IF YOU HAD A DIRTY NEW RECORD THEN IT IS NO LONGER A NEW RECORD BECAUSE OF
THE CODE ABOVE.
'if we are on a new record, give user a message
If Me.NewRecord Then
MsgBox "You must complete the store and date" _
, , "Cannot create questions"
Exit Sub
End If
If IsNull(Me.InspID) Then
MsgBox "You must fill out the store and date" _
, , "Cannot create questions"
Me.InspID.SetFocus
Exit Sub
End If
Dim strSQL As String
strSQL = "INSERT INTO tblDMInspecDet (InspID, DMCatID, QstID) " _
& " SELECT " & Me.InspID _
& ", DMCatID " _
& ", QstID " _
& " FROM tblQuestions;"
CurrentDb().Execute strSQL
THE ABOVE LINE SHOULD BE:
CurrentDB.Execute strSQL, dbFailOnError
AND YOU SHOULD HAVE ERROR HANDLING CODE IN THIS FUNCTION.
'make the new records show up on the subform
Me.subfrmDMInspDet.Requery
ADD THE FOLLOWING:
Me.OtherControlName.SetFocus '-- Use YOUR OtherControlName of course.
Me.AddQsts.Enable = FALSE
End Sub
Yes. Can you post the code you have in the click event of the CommandButton[quoted text clipped - 7 lines]
please.
user can keep adding the same records. Can someone please tell me how to do
that?
--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-forms/200805/1
- References:
- Disable Command Button After Click
- From: ridgerunner
- Re: Disable Command Button After Click
- From: ruralguy via AccessMonster.com
- Re: Disable Command Button After Click
- From: ridgerunner
- Re: Disable Command Button After Click
- From: ruralguy via AccessMonster.com
- Re: Disable Command Button After Click
- From: ridgerunner
- Re: Disable Command Button After Click
- From: ruralguy via AccessMonster.com
- Re: Disable Command Button After Click
- From: ridgerunner
- Disable Command Button After Click
- Prev by Date: Re: Search Feature
- Next by Date: Re: Disable Command Button After Click
- Previous by thread: Re: Disable Command Button After Click
- Next by thread: Re: Disable Command Button After Click
- Index(es):
Relevant Pages
|