If duplicate, open a different form

G

Guest

I have a form that the after update makes sure not to duplicate the
FileName field. For some reason I can not figure out how to open a different
form if there is a duplicate. I know I need to change this part of the code,

rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark

but I'm not sure what to change it to. The form I want to open if there is
a duplicate entry is called "ERABatchFilesViewForm", and I need it to open
with the same stLinkCriteria ([FileName]) as the code below shows.

Private Sub FileName_AfterUpdate()
Dim SID As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset

Set rsc = Me.RecordsetClone

SID = Me.FileName.Value
stLinkCriteria = "[FileName]=" & "'" & SID & "'"

If DCount("FileName", "EraBatchFiles", stLinkCriteria) > 0 Then
Me.Undo
MsgBox " WARNING! File Number " _
& SID & " already exists." _
& vbCr & vbCr & "You will now been taken to that record. Make sure
that the file is not a duplicate by checking the file size.", vbInformation _
, "Duplicate Information"
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If

Set rsc = Nothing
End Sub
 
G

Guest

Forms do not control or know if there is a duplicate. Forms are linked to
tables. That is where duplicates are not allowed.

If you open another form will it not be using the same table?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top