Hi everyone, I hope anyone can help me:
I have a textbox and a save button. When I write something into the textbox and I click the save button, what I wrote into the textbox is saved in a table. However, If I click the button again the data is saved again, and therefore, duplicated. What I want is to check if the data entered in the textbox is already in the table or not. The table has three columns, a ID column, a column with text, and a column with numbers (this last column is used to connect with other table). I tried using DLookup:
variable = DLookup("Idcity","City", "Idcity = '" & Text5 & "'")
Text5 is a textbox that shows a number from other table. I used that number to identify the idcity from the table City. I used an if to check if the number exists in City table:
If variable = 0 Then
CurrentDb.Execute (Insert into...)
Else
CurrentDb.Close
However I get an error in DLookup saying that data types in criteria don't match. I've been looking for a code doing something similar but I wasn't successful, so I hope someone can help me. Thank you in advance! you're great!!