|
-
Aug 4th, 2011, 10:47 AM
#1
Thread Starter
New Member
ACCESS 2003 - Bring User to Duplicate Record
I have a data entry page for users to enter a "Case Assignment". I want to check to see if they are entering a duplicate case assignment that already exists. If so, I want to warn them, and then bring them to/populate the current form with the original record. I have done this in a different database, but am having trouble with this one. Here is the relevant code:
Code:
Dim CaseNumber as String
Dim stLinkCriteria As String
Dim rsc As dao.Recordset
Set rsc = Me.RecordsetClone
CaseNumber = Me.ProsCaseNum1.Value
stLinkCriteria = "[ProsCaseNum1]=" & "'" & CaseNumber & "'"
If (DCount("ProsCaseNum1", "tblCaseAssignment", stLinkCriteria) > 0) Then
Me.Undo
MsgBox "Warning!...etc. It will now bring you to original record"
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
Set rsc = Nothing
Exit Sub
End If
Set rsc = Nothing
I'm not sure, but I think it might have something to do with a filter?? Reason being...
Here's how the user gets to the data entry form...On a different form..the main form, they first choose a date, then they double-click on an employee's name. When they double-click on the employee's name, it opens up the data entry form by the following code:
Code:
DoCmd.OpenForm "frmtblcaseassignment", acNormal, , , acFormAdd, acWindowNormal
'--Assign fields on the data entry form with values, based on which date they were on and which employee name they double-clicked.
Forms!frmtblCaseAssignment!SentenceDate.SetFocus
Forms!frmtblCaseAssignment!SentenceDate.Text = SEdate
Forms!frmtblCaseAssignment!POID.SetFocus
Forms!frmtblCaseAssignment!POID.Value = PO
If I add a duplicate record, it warns me, but it won't take me to the original record. It stops at Me.Bookmark = rsc.Bookmark and gives me a "no current record" error.
Alternatively...if I don't open up the data entry form from the other main form (by double-clicking on employee name)...and also therefore don't assign any values to any of the data entry form's fields, it works fine. For example, in the data entry form's design view, I switch to form view. Add A duplicate record, it warns me and then takes me to the original record.
So I assume something is going on with the recordset when I open up the data entry form through the other main form. Is the recordset being filtered, so the recordsetclone is only cloning the one record?
Any help and/or suggestions are appreciated.
-
Aug 10th, 2011, 07:52 PM
#2
Hyperactive Member
Re: ACCESS 2003 - Bring User to Duplicate Record
I have personally never used the recordsetclone, so I am not to sure, I'll have to try it and find out.
My guess is that you are cloning the entire recordset that the form is set to, so you may actually have to move the 'rsc' recordset to the desired record...
Have you tried any debugging methods? Have you tried using debug.print? It prints out the values in the immediate window, so you must have the immediate window open. You can find it in the menu under view. You can try printing out different values of 'rsc' to try and figure out where it is, and what it actually contains.
IE:
Code:
debug.print rsc.recordcount
debug.print rsc![Valid Field Name]
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|