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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DCount Multiple Criteria-Formatting Issue/Data Mismatch 1

Status
Not open for further replies.

BDCarrillo

Technical User
Jul 9, 2010
30
US
Trying to prevent a duplicate record from being added by the following logic:

"If there arent any records that already have the same start date and shop code, allow record creation"

In the Roster_Data table, [Start_Date] is a date and [Shop_Code] is a Long.

sDate and sCode are pulling data from an unbound "submission" form.

Code:
Dim sDate As Date
Dim sCode As Long

sDate = Me.Start_Date1.Value
sCode = Me.Shop_Code.Value
   
    If DCount("[ID]", "Roster_Data", "[Start_Date]=  #" & sDate & "#" And [Shop_Code] = sCode) = 0 Then

I've dug around a lot and tried different formatting/syntax but keep running into problems. I'm sure its just an issue of a misplace quotation mark, but can't figure it out.
 
If DCount("ID", "Roster_Data", "Start_Date=#" & sDate & "# AND Shop_Code=" & sCode) = 0 Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top