PlasticMonster
Registered User.
- Local time
- Today, 11:30
- Joined
- Aug 21, 2012
- Messages
- 30
Hi,
I am trying to run a check that will make the user aware if the request they are adding via the form is likely to be a duplicate. If so I want the option to allow or reject the entry.
Alternatively I have seen solutions that just notify on the form is something might be a duplicate, by highlighting a textbox red for example.
There will be duplicates across these fields but there are many other options included on the form, as I said this is just an indicataion.
The table is called
"MainAc"
The form is called
"SDC Request Form"
The comparison fields are called:
"First_name" - Text
"Surname" - Text
"Change_Number" - Number
"Date_from" - Date
"Date_to" - Date
Ive been trying the Dcount() function, IIF() function but no joy.
I tried to putting the below in the before update event, but it didnt run at all, now Ive put it on the button click acion that duplicates records for me, however it just returns a non duplicate responce regardless.
(Limited to a few of the fields but I cant even get that to work properly).
Dim PreviousRecordID As Long
PreviousRecordID = 0
PreviousRecordID = DLookup("first_name", "MainAc", "first_name<>" & First_Name & _
" AND surname=" & Surname & " AND change_number=" & Change_Number)
If PreviousRecordID <> 0 Then
MsgBox "Duplicate: exists already", , vbCritical
Exit Sub
Else
MsgBox "This is not a duplicate", , vbCritical
End If
This was a copy and modify from an example database but I dont entirely understand what each part does.
Im not asking for anyone to do the work for me but a steer would be gratefully received. Microsoft tutorials seem to leave something to be desired!!
Thankyou if you read this far
I am trying to run a check that will make the user aware if the request they are adding via the form is likely to be a duplicate. If so I want the option to allow or reject the entry.
Alternatively I have seen solutions that just notify on the form is something might be a duplicate, by highlighting a textbox red for example.
There will be duplicates across these fields but there are many other options included on the form, as I said this is just an indicataion.
The table is called
"MainAc"
The form is called
"SDC Request Form"
The comparison fields are called:
"First_name" - Text
"Surname" - Text
"Change_Number" - Number
"Date_from" - Date
"Date_to" - Date
Ive been trying the Dcount() function, IIF() function but no joy.
I tried to putting the below in the before update event, but it didnt run at all, now Ive put it on the button click acion that duplicates records for me, however it just returns a non duplicate responce regardless.
(Limited to a few of the fields but I cant even get that to work properly).
Dim PreviousRecordID As Long
PreviousRecordID = 0
PreviousRecordID = DLookup("first_name", "MainAc", "first_name<>" & First_Name & _
" AND surname=" & Surname & " AND change_number=" & Change_Number)
If PreviousRecordID <> 0 Then
MsgBox "Duplicate: exists already", , vbCritical
Exit Sub
Else
MsgBox "This is not a duplicate", , vbCritical
End If
This was a copy and modify from an example database but I dont entirely understand what each part does.
Im not asking for anyone to do the work for me but a steer would be gratefully received. Microsoft tutorials seem to leave something to be desired!!
Thankyou if you read this far
