D
Debbiedo
I have a table whose field "ID" has a "No duplicates" set as a
property.
Just before refreshing my record, I want to check to make sure that
Forms!StopsTableForm!ID is not duplicated. I have the field's property
set to "No duplicates", which results in a very cryptic message from
the system when I refresh that I want to supercede with my own
message. I would like to check for duplicates and if found, have a
message box pop up that says "Duplicate Data. Closing Form.", remove
current data and close the StopsTableForm form. If data is not
duplicated, keep the form open with the current data.
How do I check for duplicate data? (Note: ID is concatenated in this
code, if that makes a difference) I'm thinking that if the data has
not been saved to the table, how does it check to see if it is a
duplicate?
What I have so far.
Private Sub OpenForm1_Click()
If IsNull(Forms!CreateStopsTableForm!PICKADD1) Then
MsgBox "Address is Null. Cannot add record", vbOKOnly, "Warning"
Else
DoCmd.OpenForm "StopsTableForm", , , , acFormAdd
Forms!StopsTableForm!StudID = Forms!CreateStopsTableForm!StudID
Forms!StopsTableForm!ID = Forms!CreateStopsTableForm!ID & "A"
Forms!StopsTableForm!ADDRESS = Forms!CreateStopsTableForm!PICKADD1
Forms!StopsTableForm!PU_DO_CODE = "PU1"
' Check for duplicate data code here, I think
Forms("StopsTableForm").Refresh
End If
End Sub
Thanks in advance for any and all help.
property.
Just before refreshing my record, I want to check to make sure that
Forms!StopsTableForm!ID is not duplicated. I have the field's property
set to "No duplicates", which results in a very cryptic message from
the system when I refresh that I want to supercede with my own
message. I would like to check for duplicates and if found, have a
message box pop up that says "Duplicate Data. Closing Form.", remove
current data and close the StopsTableForm form. If data is not
duplicated, keep the form open with the current data.
How do I check for duplicate data? (Note: ID is concatenated in this
code, if that makes a difference) I'm thinking that if the data has
not been saved to the table, how does it check to see if it is a
duplicate?
What I have so far.
Private Sub OpenForm1_Click()
If IsNull(Forms!CreateStopsTableForm!PICKADD1) Then
MsgBox "Address is Null. Cannot add record", vbOKOnly, "Warning"
Else
DoCmd.OpenForm "StopsTableForm", , , , acFormAdd
Forms!StopsTableForm!StudID = Forms!CreateStopsTableForm!StudID
Forms!StopsTableForm!ID = Forms!CreateStopsTableForm!ID & "A"
Forms!StopsTableForm!ADDRESS = Forms!CreateStopsTableForm!PICKADD1
Forms!StopsTableForm!PU_DO_CODE = "PU1"
' Check for duplicate data code here, I think
Forms("StopsTableForm").Refresh
End If
End Sub
Thanks in advance for any and all help.