Data Validation - Help Required

D

Dave

I have a tempory table to which a lit of part number are pasted from Excel.
I need to validate these numbers for being Known or New parts
I have the following code that finds "New" part numbers and inserts them in
the "tblnewparts" table - this works fine.
I can't find a way of inserting the "Known" records in to tblxfileboms" then
deleting all records from the tempory table.

Can any one help??

Dave


Private Sub btnvalidate_Click()
On Error Resume Next

Dim rsTarget As DAO.Recordset
Dim rsSource As DAO.Recordset
Dim strSQL As String
Dim Cancel As Boolean



Set rsSource = CurrentDb.OpenRecordset("tbltemp")
Set rsTarget = CurrentDb.OpenRecordset("tblnewparts")


If Not rsSource.BOF Then
Do Until rsSource.EOF
If IsNull(DLookup("[IZPN]", "tblpartsdatabase", "[IZPN] = '" &
rsSource("partno") & "'")) Then
If MsgBox("This is a New Part - Do You Wish To Add?",
vbYesNo, "Project Costing Database") = vbNo Then
' do nothing
Else
rsTarget.AddNew
rsTarget("xfile") = rsSource("xfile")
rsTarget("issue") = rsSource("issue")
rsTarget("partno") = rsSource("partno")
rsTarget("qty") = rsSource("qty")
rsTarget.Update

End If
End If
rsSource.MoveNext
Loop

End If
rsTarget.Close
rsSource.Close

Set rsTarget = Nothing
Set rsSource = Nothing

End Sub
 
S

Svetlana

If IsNull(DLookup("[IZPN]", "tblpartsdatabase", "[IZPN] = '" &
rsSource("partno") & "'"))=True Then
You add the new item the way you do it
Else
You add the known item to the tblxfileboms
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top