I am having trouble with a command button I created on the last of several subforms within a parent form. What I would like the command button to accomplish is, OnClick, for the user to be re-directed to the first control on the form and to then be able to add a new record on the form. Here is the code I have been using:
Private Sub Command95_Click()
On Error GoTo Err_Command95_Click
'command button to enter next interview at start of form
Me.Parent.Form.Text30.SetFocus
DoCmd.GoToRecord , , acNewRec
Exit_Command95_Click:
Exit Sub
Err_Command95_Click:
MsgBox Err.Description
Resume Exit_Command95_Click
End Sub
(I have also tried variants of the SetFocus line -- all of which have been successful for me in other, very similar form/subform command button addnew situations.)
Here is the problem: 1) when the user clicks the command button, occassionally a double screen appears (as though the subforms are overlapping), 2) when the command button does as it is supposed to, the tab order after the first control on the form goes completely out of whack such that the first time around it goes in the appropriate order, the second time around (i.e., after the next click through to the new record) it jumps down a row to another control, and continues to jump through this unspecified pattern of controls until it starts at the 4th incorrect control on each attempt at entering a new record coming from the command button in question. Each of the incorrect controls one is directed to has AfterUpdate code behind it along the lines that follow (they each vary slightly):
Private Sub Combo20_AfterUpdate()
Select Case Me.Combo20
Case 1
DoCmd.GoToControl "combo24"
Case 2
Me.Combo24 = 2
Me.Combo33 = 2
Me.Combo39 = 2
Me.Combo45 = 2
Me.Combo51 = 2
DoCmd.GoToControl "combo57"
Case Else
DoCmd.GoToControl "combo57"
'if yes to any alzheimers in family answer questions about specific family members,
' if no to any alzheimers in family, answer no to questions about specific family
' members and jump to next category of questions, else jump to next category of questions
End Select
End Sub
This is the only aspect of my programming that differs from very, very similar (and successful) programming I have implemented on other forms/subforms so I thought it important to include here.
Any guesses on what might be causing these problems and how I might solve them??? Your help will be greatly appreciated!!!!
-EH
Private Sub Command95_Click()
On Error GoTo Err_Command95_Click
'command button to enter next interview at start of form
Me.Parent.Form.Text30.SetFocus
DoCmd.GoToRecord , , acNewRec
Exit_Command95_Click:
Exit Sub
Err_Command95_Click:
MsgBox Err.Description
Resume Exit_Command95_Click
End Sub
(I have also tried variants of the SetFocus line -- all of which have been successful for me in other, very similar form/subform command button addnew situations.)
Here is the problem: 1) when the user clicks the command button, occassionally a double screen appears (as though the subforms are overlapping), 2) when the command button does as it is supposed to, the tab order after the first control on the form goes completely out of whack such that the first time around it goes in the appropriate order, the second time around (i.e., after the next click through to the new record) it jumps down a row to another control, and continues to jump through this unspecified pattern of controls until it starts at the 4th incorrect control on each attempt at entering a new record coming from the command button in question. Each of the incorrect controls one is directed to has AfterUpdate code behind it along the lines that follow (they each vary slightly):
Private Sub Combo20_AfterUpdate()
Select Case Me.Combo20
Case 1
DoCmd.GoToControl "combo24"
Case 2
Me.Combo24 = 2
Me.Combo33 = 2
Me.Combo39 = 2
Me.Combo45 = 2
Me.Combo51 = 2
DoCmd.GoToControl "combo57"
Case Else
DoCmd.GoToControl "combo57"
'if yes to any alzheimers in family answer questions about specific family members,
' if no to any alzheimers in family, answer no to questions about specific family
' members and jump to next category of questions, else jump to next category of questions
End Select
End Sub
This is the only aspect of my programming that differs from very, very similar (and successful) programming I have implemented on other forms/subforms so I thought it important to include here.
Any guesses on what might be causing these problems and how I might solve them??? Your help will be greatly appreciated!!!!
-EH