Re: Preventing Duplicate Records



On Jan 17, 9:38 am, "ruralguy via AccessMonster.com" <u12102@uwe>
wrote:
Please post your DCount() code so we can see it.

rjshra...@xxxxxxxxx wrote:
On Jan 16, 9:55 pm, "ruralguy via AccessMonster.com" <u12102@uwe>
wrote:
Have you tried using DCount() of DLookup() before saving?http://www.mvps.org/access/general/gen0018.htm

[quoted text clipped - 23 lines]

- Show quoted text -

I have played with both and understand how to use DCount to retrieve
the number of occurrences of a record and with DLookup to retrieve a
value. I added a MSGBOX (variable) to display the results so I could
see what was being retrieved or counted....but I do not understand how
to use them to check for the duplicate.

--
RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP WinXP Pro
Please post back to this forum so all may benefit.

Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/2008...

ScanCount = DCount("StatusDate", "tblStatus", "CustomerID = '" &
Me.txtCustomerID.Value & "'")
Msgbox (ScanCount)

I then have this code that runs before saving the record to the table

If ScanCount > 0 then
msg = "Customer ID can only be scanned once per day; this ID number
has already been scanned today."
Style = vbInformation
Title = "Failed Scan Attempt"
Response = MsgBox(msg, Style, Title)
Me.txtCustomerID.SetFocus
Exit Sub
End If


What I find is that I will scan the customers id number yesterday and
then when I go to scan it again today I get the error message that I
have generated. After thinking about it it makes sense that I have
scaned it and if it is > than 0 (which it is) return th error message.
I'm just not getting how to check for a certain date I guess as
apposed to a count of the total number of dates.
.



Relevant Pages

  • Re: Preventing Duplicate Records
    ... Msgbox (ScanCount) ... I then have this code that runs before saving the record to the table ... If ScanCount> 0 then ... scaned it and if it is> than 0 return th error message. ...
    (comp.databases.ms-access)
  • Re: You cant go to the specified recordset message
    ... do you see the error message only on one or more specific If statements, ... Yes my custom msgbox does open. ... Cancel = True ...
    (microsoft.public.access.formscoding)
  • Re: [VB5] error 5 on unload form
    ... Was the error announced in a msgbox of your own, ... contain no error handling (I am aware of the error handling in case ... You asked for the origin of the error message. ... The sub in the main module is executed to its very end, ...
    (comp.lang.basic.visual.misc)
  • Error Message different in MDB and MDE
    ... In an MDB, an unhandled error in a form event gets a VB msgbox, with a VBA ... error message. ... The same unhandled error in an MDE gets an Access msgbox, ...
    (microsoft.public.access.formscoding)
  • Error Message different in MDB and MDE
    ... In an MDB, an unhandled error in a form event gets a VB msgbox, with a VBA ... error message. ... The same unhandled error in an MDE gets an Access msgbox, ...
    (microsoft.public.access.modulesdaovba)