I have what should be a simple problem but cannot get a simply DoLookUp to work. I have spent the last hour running through your searches but jsy can't fix it.
I have a table of Unique Part Nos and just want to do a simple user message to prevent any duplicates being entered. I know the table won't accept any duplicates but when my button closes the form, it doesn't tell you that the record has not been written. Interestingly, you do get a warning when using the X close rather than a simple form close command button.
Dim strSearch as String
varX as Variant
strSearch = Part_Number.Text
varX = DLookup("Part_Number", "Components", "' " & strSearch & "'")
MsgBox varKey
If Not IsNull(varX) Then
If MsgBox("This Part Number already exists." & vbNewLine & vbNewLine & _
"Do you wish to continue to create a new component entry?", vbYesNoCancel) = vbYes Then
Me.Undo
Part_Number.SetFocus
Else
Cancel = True
Me.Undo
End If
End If
Thanks you wonderful people
I have a table of Unique Part Nos and just want to do a simple user message to prevent any duplicates being entered. I know the table won't accept any duplicates but when my button closes the form, it doesn't tell you that the record has not been written. Interestingly, you do get a warning when using the X close rather than a simple form close command button.
Dim strSearch as String
varX as Variant
strSearch = Part_Number.Text
varX = DLookup("Part_Number", "Components", "' " & strSearch & "'")
MsgBox varKey
If Not IsNull(varX) Then
If MsgBox("This Part Number already exists." & vbNewLine & vbNewLine & _
"Do you wish to continue to create a new component entry?", vbYesNoCancel) = vbYes Then
Me.Undo
Part_Number.SetFocus
Else
Cancel = True
Me.Undo
End If
End If
Thanks you wonderful people
