B
BonnieW
I'm having a heck of a time with this form & form-switching.
I have a form called "tablepeople" (I didn't name it- I know, I know), in
which the user chooses a person or creates a new one. When this is done,
they hit a button, which checks to make sure that they have, in fact, done
so; if they have, it moves to the next form. However, the next form (called
frmVolEffortGen), may or may not already be open. If it is open, I want it
to get the new data from "tablepeople" and the focus. If it is not open, I
want it to be opened, get the data, and have focus. This is the code I have.
Private Sub Command28_Click()
'the "record the valiant effort of this volunteer" button
On Error GoTo Err_Command28_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmVolEffortGen"
'check to see that a name is actually selected
If IsNull(Me!LastName) Then
MsgBox "Choose a volunteer, or create a new one."
Cancel = True
Me!Combo26.SetFocus
'if frmVolEffortGen is loaded
ElseIf CurrentProject.AllForms("frmVolEffortGen").IsLoaded Then
'update the control with names
Forms![frmVolEffortGen].Requery
DoCmd.GoToRecord , , acNext, 1
'following setfocus not working on that (or any) field
'Forms![frmVolEffortGen]![EffortDate].SetFocus
Else
'open the form (@newrecord), set focus to a control
DoCmd.OpenForm "frmVolEffortGen"
DoCmd.GoToRecord , , acNewRec
'DoCmd.GoToControl "EffortDate"
End If
The first IF condition works fine- it won't let me get past it if I forget to
choose a volunteer. It also has no problem loading up "frmVolEffortGen" if
it is not open. However, if "frmVolEffortGen" is open, it gets neither the
focus nor the data. How can I fix that?
(Bonus question: whenever I try to shift focus to a control, Access tells me
it can't shift focus to that control. Doesn't matter if they're text,
visible, enabled, combobox or subform- I've tried 'em all. Any idea why?)
I have a form called "tablepeople" (I didn't name it- I know, I know), in
which the user chooses a person or creates a new one. When this is done,
they hit a button, which checks to make sure that they have, in fact, done
so; if they have, it moves to the next form. However, the next form (called
frmVolEffortGen), may or may not already be open. If it is open, I want it
to get the new data from "tablepeople" and the focus. If it is not open, I
want it to be opened, get the data, and have focus. This is the code I have.
Private Sub Command28_Click()
'the "record the valiant effort of this volunteer" button
On Error GoTo Err_Command28_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frmVolEffortGen"
'check to see that a name is actually selected
If IsNull(Me!LastName) Then
MsgBox "Choose a volunteer, or create a new one."
Cancel = True
Me!Combo26.SetFocus
'if frmVolEffortGen is loaded
ElseIf CurrentProject.AllForms("frmVolEffortGen").IsLoaded Then
'update the control with names
Forms![frmVolEffortGen].Requery
DoCmd.GoToRecord , , acNext, 1
'following setfocus not working on that (or any) field
'Forms![frmVolEffortGen]![EffortDate].SetFocus
Else
'open the form (@newrecord), set focus to a control
DoCmd.OpenForm "frmVolEffortGen"
DoCmd.GoToRecord , , acNewRec
'DoCmd.GoToControl "EffortDate"
End If
The first IF condition works fine- it won't let me get past it if I forget to
choose a volunteer. It also has no problem loading up "frmVolEffortGen" if
it is not open. However, if "frmVolEffortGen" is open, it gets neither the
focus nor the data. How can I fix that?
(Bonus question: whenever I try to shift focus to a control, Access tells me
it can't shift focus to that control. Doesn't matter if they're text,
visible, enabled, combobox or subform- I've tried 'em all. Any idea why?)