A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Replace Error 3022 VBA with specific field labels



 
 
Thread Tools Display Modes
  #1  
Old September 28th, 2009, 10:14 PM posted to microsoft.public.access.gettingstarted
Lostguy
external usenet poster
 
Posts: 73
Default Replace Error 3022 VBA with specific field labels

Hello!

tblEmployee with EmployeeIDpk and LName (holds employee data)
tblEvent with EventIDpk and Event (holds event data) (Check-in,
orientation, CPR training, etc.)
tblEmpEvent with EmployeeIDfk and EventWhenIDfk (holds which
employees did which events)
tblEventWhen with EventWhenIDpk, EventIDfk, EventDate (holds when each
event happened)

I use a mainform based on tblEventWhen where I enter the date and then
select the event via a combobox tied to tblEvent.
On that mainform is a continouus subform where I select which
employees did that event

Some rules:
1) An event cannot happen more than once a day. (EventDate and Event
are the same)
2) An employee cannot do the same event more than once. (Event and
EmployeeIDpk are the same)

For #1, I use the following:

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If DataErr = 3022 Then
MsgBox "This combination of date and event has already been entered. "
& "Please use the previous entry to prevent duplication of data.",
vbExclamation, "Duplicate Date-Event Combination"
Response = acDataErrContinue
End If
End Sub


I am stumped about #2 and would like to do away with the whole Error
3022 route for #1, and go with some VBA like:

If the combination of EventDate and Event, or the combination of Event
and EmployeeIDfk, contain duplicates, display a messagebox stating
"[LName] previously completed the [Event] event on [EventDate]. Please
update or delete the previous entry, then reenter the new event data."

(I set up two duplicate records queries and that works, but it catches
duplicates after entry instead of as they are being entered.)

??

VR/Lost
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:03 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.