473,399 Members | 3,656 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,399 software developers and data experts.

Modifying DCount Function

iBasho
16
Hi
I am using the DCount function to check and alert users for existing IDs in my database after a new record is entered.

Expand|Select|Wrap|Line Numbers
  1. ..Private Sub CARDID_AfterUpdate()
  2. If DCount("*", "[qryDay60]", "[CARDID] = '" & Me.[CARDID] & "'") Then
  3. MsgBox "This card ID number already exists in the system. Once you enter the dependent code you will be able to determine if this is a subsequent reinbursement submission from the same member or a new submission from another subscriber on the same policy. Please check to make sure that the member was NOT initially ineligible."
  4. End If
  5. End Sub..
I am trying to modify it so that it looks only at records with the same ID in year 2008. The YEAR field is set up as text.
I tried to add this condition in the criteria section of the DCount function, but that got me nowhere. I still get the msgbox for existing records in 2007 with the same ID.

Any idea on how to fix this?

Thanks.
Jan 3 '08 #1
1 1809
PianoMan64
374 Expert 256MB
Can you provide some more detail as to how the query that you're using is layed out. It would be much easier if you simply has a small peace of VBA to do a lookup on the ID code

Example:

Expand|Select|Wrap|Line Numbers
  1. Function CheckID(CodeID as String, CustomerName as String) as Boolean
  2.  
  3.          Dim db as DAO.Database
  4.          Dim rs as DAO.Recordset
  5.          On Error Goto Err_CheckID
  6.  
  7.          Set db = currentDb()
  8.          Set rs = db.OpenRecordSet("SELECT * FROM [DatabaseName] " & _
  9.                      "WHERE CodeID = '" & CodeID & "'" & _
  10.                      , dbOpenDynaset)
  11.           With rs
  12.                  If Not .EOF Then
  13.                          .Edit
  14.                          !FullName = CustomerName
  15.                          'Add additional fields that you want to update
  16.                          .Update
  17.                 End If
  18.           end with
  19.           CheckID = True
  20.           rs.close
  21.           db.close
  22.  
  23.           set rs = nothing
  24.           set db = nothing
  25.           exit function
  26.  Err_CheckID:
  27.      CheckID = False
  28.  
  29.           rs.close
  30.           db.close
  31.  
  32.           set rs = Nothing
  33.           set db = Nothing
  34.  
  35. End Function
  36.  
Copy and paste this code into your Module. then this way you can call it from any form or report when you need it.
Jan 5 '08 #2

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

Similar topics

7
by: jdph40 | last post by:
I posted this problem previously and received excellent help from Wayne Morgan. However, I still have an unanswered question. My form (frmVacationWeeks) is opened from the OnClick event of a...
1
by: Megan | last post by:
Hi Everybody- I've been reading some of the posts about DCOUNT, and I haven't yet found an answer; so, I'm posting this question. I have a report that I'm trying to use DCOUNT on to compute...
4
by: Will | last post by:
Hi, I had a DCount within a module on records in a table where CustSuffix = 0. I now need to DCount where CustSuffix = 0 and the type of cost Suffix (Suffix in table) = G. I can't get both...
6
by: Mike Conklin | last post by:
This one really has me going. Probably something silly. I'm using dcount for a report to determine the number of different types of tests proctored in a semester. My report is based on a...
3
by: BerkshireGuy | last post by:
I am having difficulty with using the Dcount function. I am trying to return the number of records from qryIndividualFeedbackDetail where the TimelyManner field is set to 4. So, in the new...
2
by: ChasW | last post by:
Greetings, I have a form that uses a query as its record source. In the form I have a text box that uses this as its control source: =DCount("", "qry_Search_by_Name") The DCount function...
2
by: Wingz | last post by:
Hiya, Fairly new to Access and was wondering what the best way to perform Dcounts on groups in an Access report. For example, I have 10 employees and the different instances of jobs they can...
36
by: bmyers | last post by:
Good afternoon, I am attempting to count only those records within a report, which is based on a query, where Status is equal to Closed. I have tried multiple variations of DCOUNT but am...
8
by: Susan Bricker | last post by:
I have used DCount() to determine the number of records in a recordset. Silly me ... I just noticed that DCount returns an INTEGER, which can hold a maximum value of 32,767. What if the recordset...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.