B
BonnieW
Hello!
I have a form (Form2) which is being opened (or sometimes set focus to) from
another form (Form1). On the open and gotfocus events, I want it to go to a
new record; however, I also want it to be able to see/edit previous records
(so the DataEntry mode option is right out).
-I have no OnGotFocus, OnLoad, etc events in Form2
-the code on Form1 calling Form2 is on a command button. I've included the
whole mess of code on that button, just in case I'm missing something
dreadfully obvious:
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
'go to the form...
Forms![frmVolEffortGen].SetFocus
'DoCmd.GoToRecord , frmVolEffortGen, acNewRec
DoCmd.GoToRecord , , acNewRec
'DoCmd.GoToRecord , , acLast, 1
'Forms![frmVolEffortGen]![VolName].Requery
Else
'open the form (@newrecord), set focus to a control
DoCmd.OpenForm "frmVolEffortGen"
DoCmd.GoToRecord , , acNewRec
'DoCmd.GoToRecord , , acLast, 1
'DoCmd.GoToControl "EffortDate"
End If
Exit_Command28_Click:
Exit Sub
Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click
End Sub
Thanks in advance for any help you can offer. You all have been most helpful
in the past.
I have a form (Form2) which is being opened (or sometimes set focus to) from
another form (Form1). On the open and gotfocus events, I want it to go to a
new record; however, I also want it to be able to see/edit previous records
(so the DataEntry mode option is right out).
-I have no OnGotFocus, OnLoad, etc events in Form2
-the code on Form1 calling Form2 is on a command button. I've included the
whole mess of code on that button, just in case I'm missing something
dreadfully obvious:
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
'go to the form...
Forms![frmVolEffortGen].SetFocus
'DoCmd.GoToRecord , frmVolEffortGen, acNewRec
DoCmd.GoToRecord , , acNewRec
'DoCmd.GoToRecord , , acLast, 1
'Forms![frmVolEffortGen]![VolName].Requery
Else
'open the form (@newrecord), set focus to a control
DoCmd.OpenForm "frmVolEffortGen"
DoCmd.GoToRecord , , acNewRec
'DoCmd.GoToRecord , , acLast, 1
'DoCmd.GoToControl "EffortDate"
End If
Exit_Command28_Click:
Exit Sub
Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click
End Sub
Thanks in advance for any help you can offer. You all have been most helpful
in the past.