I am trying to recreate some DLookup code in .net.....but having some difficulties. All I want to do is lookup existing table data so as to validate against user textbox duplicates....if there is a duplicate record then provide an error message, followed by inserting the duplicate into an errorlog table!! I have looked at datarow methods but lack the .net skills to put this together. Can anyone help? Here's the context:
Dim FoundDuplicateFileName, Criteria As String
Static subCalls As Integer
Criteria = "[FileName] =" & txtFileName.Text
FoundDuplicateID = DLookup("[FileName]", "PinkGradingLoggingData", Criteria)
Dim Msg2 As String, Style2 As Integer, Title2 As String
Dim Msg3 As String, Style3 As Integer, Title3 As String
'Dim row As DataRow = dsLogging.PinkGradingLoggingData.Rows.Find(FoundDuplicateFileName)
If Not IsDBNull(FoundDuplicateFileName) Then
subCalls = subCalls + 1
Msg2 = "Duplicate FileName'," & txtFileName.Text & "'"
Style2 = vbInformation + vbOKOnly
Title2 = "FileName" & txtFileName.Text & "' Already in System! . . ."
MsgBox(Msg2, Style2, Title2)
If subCalls >= 2 Then
Msg3 = "Duplicate FileName '" & txtFileName.Text & "'"
Style3 = vbInformation + vbOKOnly
Title3 = "Duplicate UniquePID '" & txtFileName.Text & "' added to Errorlog"
MsgBox(Msg3, Style3, Title3)
CurrentDb.Execute("INSERT INTO DuplicationErrorLog " & "(UniquePID) VALUES (" & Me.Photoset_PID & ");")
Cancel = True
txtFileName.Undo()
txtFileName.Focus()
txtFileName.Clear()
subCalls = 0
Else
Cancel = True
txtFileName.Undo()
txtFileName.Focus()
txtFileName.Clear()
End If
Else
subCalls = 0
End If
Dim FoundDuplicateFileName, Criteria As String
Static subCalls As Integer
Criteria = "[FileName] =" & txtFileName.Text
FoundDuplicateID = DLookup("[FileName]", "PinkGradingLoggingData", Criteria)
Dim Msg2 As String, Style2 As Integer, Title2 As String
Dim Msg3 As String, Style3 As Integer, Title3 As String
'Dim row As DataRow = dsLogging.PinkGradingLoggingData.Rows.Find(FoundDuplicateFileName)
If Not IsDBNull(FoundDuplicateFileName) Then
subCalls = subCalls + 1
Msg2 = "Duplicate FileName'," & txtFileName.Text & "'"
Style2 = vbInformation + vbOKOnly
Title2 = "FileName" & txtFileName.Text & "' Already in System! . . ."
MsgBox(Msg2, Style2, Title2)
If subCalls >= 2 Then
Msg3 = "Duplicate FileName '" & txtFileName.Text & "'"
Style3 = vbInformation + vbOKOnly
Title3 = "Duplicate UniquePID '" & txtFileName.Text & "' added to Errorlog"
MsgBox(Msg3, Style3, Title3)
CurrentDb.Execute("INSERT INTO DuplicationErrorLog " & "(UniquePID) VALUES (" & Me.Photoset_PID & ");")
Cancel = True
txtFileName.Undo()
txtFileName.Focus()
txtFileName.Clear()
subCalls = 0
Else
Cancel = True
txtFileName.Undo()
txtFileName.Focus()
txtFileName.Clear()
End If
Else
subCalls = 0
End If