473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

DCount Syntax for Numbers-Creating Duplicates Warning

Hello,

I am creating a form that displays invoice entries that contractors submit for payment. At the top of my Access form I have a control that should display a duplicates warning if the record has a duplicate order number [OrderNo] or project id [ProjectID] that is already in the tblInvoiceSubmissions. The contractors can only be paid once per order/project.

I am currently using an expression with the DCount function but it occurred to me that unlike the sample I based this expression off, my fields are data type-number and not text.

I currently have...

=IIf(DCount("*","[tblInvoiceSubmissions]","[ID]<>" & Nz([ID],0) & " And [OrderNo] = '" & Replace(Nz([OrderNo]),"'","''") & "'")>0,"Possible Duplicate Order","")

Can anyone tell me how to re-write this being that[OrderNo] is a number. And how to add that the [ProjectID] field should be counted as well.
I'm trying to say...
If number of occurrences in which the same [OrderNo] or [ProjectID] within the table "tblInvoiceSubmissions" is greater than 0 display "Possible duplicate order".

I tried just removing the quotes but I wasn't sure which ones. It has been impossible to find examples of DCount syntax for numbers only text. Any help that can be offered would be a Godsend. I have a tight deadline and this is the last function to be added. Thanks for your help in advance!
Aug 13 '14 #1
1 1242
twinnyfo
3,653 Expert Mod 2GB
analystntrg,

Here is a possible solution:

Expand|Select|Wrap|Line Numbers
  1. =IIf(DCount("*", "tblInvoiceSubmissions", _
  2.     "[OrderNo] = " & Nz([OrderNo], 0) & _
  3.     " Or [ProjectID] = " & Nz([ProjectID], 0)) > 0, _
  4.     "Possible Duplicate Order","")
  5.  
This assumes that both your Order Number and Project ID are true numerical values and not strings. I changed the logic to solve for positive results and eliminated the possibility of Null values as you had.

Keep in mind that using the DCount Function, although funcitonal, will slow down tremendously once you start adding lots of records. There may be better ways to do this through VBA coding behind your Form, but, based on your question, this may serve as an initial solution. (I hope I got the syntaxt correct)
Aug 13 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: lost | last post by:
sorry for the basic question, but: I have users entering a serial number on a form in a text box that is bounded and called via a query. Prior to allowing that number to be entered into the...
15
by: sara | last post by:
Hi I'm pretty new to Access here (using Access 2000), and appreciate the help and instruction. I gave myself 2.5 hours to research online and help and try to get this one, and I am not getting...
7
by: kaosyeti | last post by:
hey.. i have a control in a report that needs to count the records from a table that match the parameters that the user selects when creating the report. the report is created with...
1
by: Blue Lagoon Products - Customer Services | last post by:
Hi, Here is my expression =DCount("","tblDownload")>2 I would like to know how many records (including this one?) contain the same 'Buyer ID' as that in txtBuyerID on my report, is this...
9
by: paul.jameson | last post by:
I have a simple Access database that stores Karaoke Songlists for my local pub. From this you are able to print out the song lists they use. Up until now, any duplicate songs that appear on say,...
7
by: favor08 | last post by:
How can I tie the users shortname to this code. so it comes back with the results that only apply to them. Dim pastdue As Integer Dim current As Integer Dim tot As Integer nodate =...
3
by: Lester | last post by:
I'm driving myself crazy with a problem in trying to translate a query written for Access to that for SQL server. I would think that I would use a trigger, but am not sure how to set it up. We...
7
by: john.cole | last post by:
I have searched all the groups I can, and I still haven't been able to come up the solution I need. I have the following problem. In my form named sbfrmSpoolList, I am entering a job, spool and...
5
by: trey3143 | last post by:
Have this code to check for duplicates and if I change my BoxID to a text and run it as a string it works, but I need it to be a Long Integer. The data mismatch I am getting is underlined there are...
0
by: Matt Houser | last post by:
Hello, I am not great with coding but I am trying to run code in the before update event procedure on a form to make sure that there isnt already a record that matches the current entry. My Table...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.