Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / July 2006

Tip: Looking for answers? Try searching our database.

data entry via query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Cline - 27 Jul 2006 21:39 GMT
I've made a database that allows data to be input through webpages.  I want
to be able to make data entry as fool proof as possible by preventing people
from inputting data that causes impossible situations on the other end of a
calculation.  For example, I'm having people input the length of their shift
and the amount of time a particular machine is down for a repair.  In my
efficiency calculation problems arise if the person accidentally entered a
larger number for machine downtime than they did for their shift length.  I
have thought about remedying the situation by linking the input blanks on the
website to a query rather than a table and putting validation rules on the
query saying that the difference between machine downtime and shift length
cannot be less than 0.  Is it possible for data to be entered with a query?  
Or is there a way to create calculated validation rules within the table that
the website is currently linked to?  Thanks in advance.
Jamie Collins - 28 Jul 2006 09:31 GMT
> I want
> to be able to make data entry as fool proof as possible by preventing people
[quoted text clipped - 9 lines]
> Or is there a way to create calculated validation rules within the table that
> the website is currently linked to?

You should always put validation rules in the database (e.g. CHECK
constraints) of course. To use a very simple example:

CREATE TABLE Test (
col1 INTEGER NOT NULL,
col2 INTEGER NOT NULL,
CHECK (col1 < col2)
);

You could write a procedure (parameter query) like this:

CREATE PROCEDURE TestProc1 (
arg_col1 INTEGER,
arg_col2 INTEGER
) AS
INSERT INTO Test (col1, col2)
VALUES (arg_col1, arg_col2);

However, when the parameter values fail the check you get an error e.g.

EXECUTE TestProc1 1, 2;  -- No error, one row affected
EXECUTE TestProc1 99, 3;  -- Error

To answer your question, yes you can use a query to ensure only valid
data is used. To revise the above proc:

CREATE PROCEDURE TestProc2 (
arg_col1 INTEGER,
arg_col2 INTEGER
) AS
INSERT INTO Test (col1, col2)
SELECT DISTINCT arg_col1 AS col1, arg_col2 AS col2
FROM Test AS T1
WHERE arg_col1 < arg_col2;

Invalid (integer) values no long cause an error:

EXECUTE TestProc1 1, 2;  -- No error, one row affected (insert
succeeds)
EXECUTE TestProc1 99, 3;  -- No error, no rows affected (insert fails)

Jamie.

--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.