S
Someone
Hello
I have 10 separate fields that contain numbers. The fields are formatted as
text because they need to have a 0 (zero) at the beginning. The fields
cannot be indexed as 'no duplicates', because duplication may occur on
occasion.
The code below demonstrates how I check whether the number being inputted
has been used before. While it works, it only checks the input against
information inputted in that field only - it doesn't check numbers inputted
previously in any of the other 9 fields. The field names increment by one
(e.g. field1, field2, field3 etc). The field and table names below are not
the real words used.
Could somebody assist in telling me how I can check the inputted number
against the information in ANY of the 10 fields in the table, please?
If Me.NewRecord Then
If DCount("[Field_Name]", "tbl_Name", "[Field_Name] = """ & Me![txt_Name] &
"""") > 0 Then
strName = txt_Name
If MsgBox("Message here" & vbCrLf & vbCrLf & "Would you like to close this
form and look up the previously queried number?", vbYesNo + vbQuestion,
Me.txt_Name & " already queried") = vbYes Then
Me.Undo
'strName used because after using an Undo, the txt_Name field is then empty
DoCmd.OpenForm "frm_Name", , , ("[Field_Name] = """ & strName & """")
End If
End If
I have 10 separate fields that contain numbers. The fields are formatted as
text because they need to have a 0 (zero) at the beginning. The fields
cannot be indexed as 'no duplicates', because duplication may occur on
occasion.
The code below demonstrates how I check whether the number being inputted
has been used before. While it works, it only checks the input against
information inputted in that field only - it doesn't check numbers inputted
previously in any of the other 9 fields. The field names increment by one
(e.g. field1, field2, field3 etc). The field and table names below are not
the real words used.
Could somebody assist in telling me how I can check the inputted number
against the information in ANY of the 10 fields in the table, please?
If Me.NewRecord Then
If DCount("[Field_Name]", "tbl_Name", "[Field_Name] = """ & Me![txt_Name] &
"""") > 0 Then
strName = txt_Name
If MsgBox("Message here" & vbCrLf & vbCrLf & "Would you like to close this
form and look up the previously queried number?", vbYesNo + vbQuestion,
Me.txt_Name & " already queried") = vbYes Then
Me.Undo
'strName used because after using an Undo, the txt_Name field is then empty
DoCmd.OpenForm "frm_Name", , , ("[Field_Name] = """ & strName & """")
End If
End If