Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bocking Duplicate Requests, How do you

Status
Not open for further replies.

claytonjgordon

Technical User
Jul 21, 2004
37
US
I would think this would be a common request and thus already covered in some thread or another but I've been looking for a few hours and didn't see any. If this has already been covered somewhere that you are aware of, please point me in the right direction.

Here goes:

I created a database that takes incoming requests from the main work group and queues up work for a support work group. The database was working as intended but the support group has indicated that they are getting duplicate request for the main group, i.e., employee one submits the request and then later employee two submits the same request not knowing that employee one has already done it.

The support group has asked that I somehow block this from happening.

The way I see it working is by creating a new form where they enter an account number and a specific date relevant to that request (not that actual days date, a date that drives the function the support group performs). These two things together act like a primary key. Either one can be duplicated, but not both. If they are, it’s a duplicate request.

So, on this new form they enter the account number and this special date and hit a button. Then I see it running a query or something somehow (this is the part I can't conceptualize) and it checks to see if there is already a record with both that Acct number and date. If there is, then I would want to generate a MsgBox saying something to the effect of "this is a duplicate request, please reference ID number" &_[Main table].ID; and then close the form and bring them back to the main menu.

If there isn't a matching record, then it takes the values in the two fields from the new form and populates them on the main request form where they can continue to fill out the form and everything else would continue as normal.

The part I can't figure out how to do is the check to see if there is a record on the main form that has the same account number and FLD(date)as entered on the form.

In a fumbling attempt to solve the problem I created this code which is supposed to create a temp table in the memory of any record that has a matching account number but it doesn't seem to be working and I don't know if I'm heading in the wrong direction to achieve the goal stated above.

Code:
Private Sub StartRecordButton_Click()

Dim db As Database
Dim rs As Recordset
Dim SQL As String

SQL = "SELECT [Main Table].* " & _
        "FROM [Main Table] " & _
        "WHERE ((([Main Table].Acct_)= " & LoanNumber & ")) "


Set db = DBEngine(0)(0)
Set rs = db.OpenRecordset(SQL)

DoCmd.Save

End Sub


Any help or insight you could provide would be greatly appreciated.

Thank you in advance!


Dominus Nihil
(Master of Nothing)
 
I got DLookup to work for the Acct# but it keeps returning a null value for the date field when it should be finding a match.

This one works like a champ and assigns the matching loan number from the table to the variable Dup. If there isn't a match, it returns a null value which is perfect
Code:
Dim Dup As Variant

Dup = DLookup("[Acct#]", "Main Table", "str([Acct#]) =" & Str(Me.LoanNumber))

But when I try to do the same thing for the date field it always passes a null value to the variant Dup3 when it should be finding a match.
Code:
Dim Dup3 As Variant
Dup3 = DLookup("[ID]", "Main Table", "[FLDD] =" & Me.CurrentFLD)

I have both date fields set up with the same format (short date) and Input Mask (99/99/0000;0;#) but it doesn't seem to recognize identical dates as being a match.



The combined code is
Code:
Dim Dup As Variant

Dup = DLookup("[ID]", "Main Table", "str([Acct#]) =" & Str(Me.LoanNumber) & " & [FLDD] =" & Me.CurrentFLD)
But since the date part isn't working, this isn't working either.

Any ideas on how to get the date part to work?


Dominus Nihil
(Master of Nothing)
 
Perhaps this ?
Dup = DLookup("ID", "[Main Table]", "[Acct#]=" & Me!LoanNumber & " AND FLDD=#" & Format(Me!CurrentFLD, "yyyy-mm-dd") & "#")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, you are a genius!!!

Thank you so much for helping me and everyone else!

Finial Code was

Code:
Dim Dup As Variant

Dup = DLookup("ID", "[Main Table]", "str([Acct#])=" & Str(Me!LoanNumber) & " AND FLDD=#" & Format(Me!CurrentFLD, "yyyy-mm-dd") & "#")



Dominus Nihil
(Master of Nothing)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top