I’m trying to make sure that no one enters the same name twice for the field “inv_server_name”.
OK - I’ve created a hidden view named “invhidden” with a column named “inv_server_name” which displays the field “inv_server_name”. This works fine.
On my form, in the Input Validation for the field “inv_server_name”, I’ve got:
AlreadyExists:=@DbLookup(“”;“”;“”;“Team only\inv_hidden”;inv_server_name;“inv_server_name”);
test:=@If(@IsError(AlreadyExists);“”;AlreadyExists);
@If(test=“”); @Failure(“Server name already exists.”); @Success;
Problem is, it never fails. I can create dupes all day long.
What have I missed?
Subject: Checking for duplicate field
This is a bit more complex than it needs to be, and you may be dropping a slash in the view name. Try:
AlreadyExist:=@DbColumn(“”;“”;“Team only\inv_hidden”;“inv_server_name”);
@If(@Contains(AlreadyExist; inv_server_name); @Failure(“Server name already exists”); @success);
And, as usual, check for stupid errors: the column name is what you think it is, the view exists (you might consider giving it a slash-free alias), and so on.
Subject: RE: Checking for duplicate field
first - thanks everybody!!
OK now trying:
AlreadyExist:=@DbColumn(“”;“”;“inv_hidden_view”;“inv_server_name”);
@If(@Contains(AlreadyExist; inv_server_name); @Failure(“Server name already exists”); @success);
now getting “incorrect datatype for the database function”
Subject: RE: Checking for duplicate field
My bad. @DBColumn takes a column number, not a name. The line should be:
AlreadyExist:=@DbColumn (“”; “”; “inv_hidden_view”; n);
…where n is the number of the desired column.
Subject: Try: @If(test=“”; @Success; @Failure(“Server name already exists.”));
Subject: divide and conquer
-
break it down into understandable pieces so that you can see what’s working
-
go with the suggestion of using a view alias in all your formulas