I have a main form . . . frmStudentEnrollment
I have a pop-up form . . . frmPhotoEntry
When the user wants to add a photograph to the main form, they click on a
button that opens the popup. When the popup opens the Win Open/Save window
opens to allow the user to select the photo. When the user has selected the
photo, they click a button to close the popup and save the file path to the
recordset. Here's the problem. I requery the main form just before the
popup closes. Of course the recordset goes back to the first record. I want
the user to stay with the record they were popping up from. I have seen the
other posting on this topic from 7/11/2006. I tried these solutions to no
avail. Here is my code for the button that saves the file name and closes
the popup:
Private Sub cmdSave_Click()
On Error GoTo Err_cmdSave_Click
Me![txtImagePath] = Me![imgTheImage].Picture
If Validate Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Echo False
Forms("frmStudentEnrollment").Form.Requery
DoCmd.Echo True
DoCmd.GoToRecord acDataForm, "Student Enrollment Upgrade",
[Student#] =" & [Forms]![frmPhotoEntry]![Student#]
DoCmd.Close acForm, Me.Name
End If
Exit_cmdSave_Click:
On Error Resume Next
Exit Sub
Err_cmdSave_Click:
MsgBox "Error " & Err.Number & " : " & Err.Description & " in
cmdSave_Click", vbExclamation, "Castle Admin"
Resume Exit_cmdSave_Click
End Sub
mscertified - 25 Jul 2007 22:46 GMT
Try something like this:
Private Sub Form_Open(Cancel As Integer)
Me.CurRec = vbNullString 'Initialize record position
End Sub
Private Sub Form_GotFocus()
' Restore record position
On Error Resume Next
If Nz(Me.CurRec, vbNullString) <> vbNullString Then
DoCmd.GoToRecord , , acGoTo, Me.CurRec
End If
End Sub
Private Sub Form_LostFocus()
' Save record position
Me.CurRec = Me.CurrentRecord
End Sub
> I have a main form . . . frmStudentEnrollment
>
[quoted text clipped - 31 lines]
> Resume Exit_cmdSave_Click
> End Sub
legere864 - 25 Jul 2007 23:08 GMT
That'll do it. Thanks a lot.
> Try something like this:
>
[quoted text clipped - 50 lines]
> > Resume Exit_cmdSave_Click
> > End Sub