Connecting Tech Pros Worldwide Forums | Help | Site Map

Validating same records from two different tables

anita
Guest
 
Posts: n/a
#1: Nov 13 '05
Hello Everybody

I have two tables(and the corresponding forms) with following fields

Table 1 (Form1)
Field1
Field2
Field3

Table 2 (Form2)
Field1
Field2
Field3
Field4
.......
Field10

When the user enter the values for Field1,Field2,Field3 in Table2 or
rather in Form2, I want to do a validation check for those values from
Table1. If the values match with the corresponding records in Table1,
it should let the user to proceed to Field4 in table2, else it should
through an error message. (Please note that the Table1 is data entered
before Table2)
Is it possible to do this, if so can annybody please help me through
with this problem.
Thanks for all your help.
I realy appreciate it

Regards

Tom van Stiphout
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Validating same records from two different tables


On 4 Nov 2004 04:59:43 -0800, tamilan71@yahoo.com (anita) wrote:

You could use DLookup to check. For example in the
Form2.Field3.AfterUpdate you could write:
if IsNull(DLookup("Field1", "Table1", "Field1=" & txtField1 & " AND
Field2=" & txtField2 & " AND Field3=" & txtField3")) then MsgBox "Bad
Boy!"

What this does is lookup any value (I would use the PrimaryKey value)
from Table1 given the values of the 3 fields. If any of these fields
are text rather than numbers, you have to wrap the values with single
quotes like this:
"Field1='" & txtField1 & "' AND...

If Table1 has many rows, say > 1000, DLookup may be too slow, and you
should write your own query to essentially do the same. Of course you
will have Table1 properly indexed with a unique index across the 3
fields.

-Tom.

[color=blue]
>Hello Everybody
>
>I have two tables(and the corresponding forms) with following fields
>
>Table 1 (Form1)
>Field1
>Field2
>Field3
>
>Table 2 (Form2)
>Field1
>Field2
>Field3
>Field4
>......
>Field10
>
>When the user enter the values for Field1,Field2,Field3 in Table2 or
>rather in Form2, I want to do a validation check for those values from
>Table1. If the values match with the corresponding records in Table1,
>it should let the user to proceed to Field4 in table2, else it should
>through an error message. (Please note that the Table1 is data entered
>before Table2)
>Is it possible to do this, if so can annybody please help me through
>with this problem.
>Thanks for all your help.
>I realy appreciate it
>
>Regards[/color]

Closed Thread