Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add to table afterupdate

Status
Not open for further replies.

rjoshi2

Programmer
Sep 10, 2002
110
US
I am not sure why my code is not working. I want to added the data to my table if the data does not exist in the table yet. Any help would be approached.

Thank You,
rjoshi2

here is my code:

Private Sub Object_Class_Description_AfterUpdate()
Dim sSQL As String
If Not Me.Object_Class = DLookup("[strClass]", "[tblObjClsDesc]") Then
sSQL = "INSERT INTO tblObjClsDesc (strClass, strDescription) VALUES (Me.Object_Class, Me.Object_Class_Description)"
CurrentDb.Execute sSQL, dbFailOnError
End If

End Sub
 
My first guess would be because DLookUp has three arguments so unless you only have one record in your table, the DLookUp isn't going to know which value in table tblObjClsDesc to look at. Try this

If Not Me.Object_Class = DLookup("[strClass]", "[tblObjClsDesc]", "[strClass]= '" & Me.Object_Class & "'") Then


Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top