PDA

View Full Version : Solved: Recordset Seek method issues



talytech
07-31-2009, 06:47 AM
I'm struggling with this. I am simply trying to check to see if a record exist in a table before I add a duplicate. I have a spreadsheet with button1 that connects to the access database, opens a recordset but my recordset.NoMatch method doesn't work. Could someone please help me out here. Here's my code:

Set wrkJet = DBEngine.Workspaces(0)
Set dbsConBI_BE = wrkJet.OpenDatabase(" URL Here ")

Set rstProvisional = dbsConBI_BE.OpenRecordset("tblProvisionalOnboardRequests", dbOpenTable)
'CHECK FOR existing record
rstProvisional.MoveLast
rstProvisional.MoveFirst

rstProvisional.Index = "UniqueID"
rstProvisional.Seek "=", ctrssn, ctrDOB, rqst


If rstProvisional.NoMatch Then 'ADD RECORD TO Provisional DATABASE
qdfNewStr = "INSERT INTO tblProvisionalOnboardRequests( FName, LName, Mid, WorkType, Vendor, Last4_SSN, DOB, HM_FirstName, HM_LastName, HM_Mid, HM_UserId, RequestDate, VP_Firstname, VP_Lastname, VP_Mid, VP_UserID,date_vp_notified, date_created, requestStatus ) " _
& "SELECT '" & ctrfname & "' AS Expr1, '" & ctrlname & "' AS Expr2, '" & ctrmid & "' AS Expr3, 'Contractor' AS Expr4, '" & ctrVendor & "' AS Expr16, '" & ctrssn & "' AS Expr17, '" & ctrDOB & "' AS Expr18, '" & mgrfname & "' AS Expr5, '" & mgrlname & "' AS Expr6, '" & mgrmid & "' AS Expr7, '" & mgruserid & "' AS Expr20, '" & rqst & "' AS Expr8, '" & vpfname & "' AS Expr12, '" & vplname & "' AS Expr13, '" & vpmid & "' AS Expr14, '" & vpuid & "' AS Expr31, " _
& " date() AS exprDate1, date() AS exprDate2,'Pending' AS ExprStatus;"

dbsConBI_BE.Execute qdfNewStr

MsgBox "Emergency On-boarding Request record was created successfully.", vbInformation, "CSR-Update Database"

Else

results = MsgBox("An EMERGENCY ON-BOARDING REQUEST WAS ALREADY ACCEPTED ON " & rqst & " FOR THIS SSN AND DOB.", vbExclamation, "Duplicate Request")
End If
End If
dbsConBI_BE.Close
wrkJet.Close