how to validate table field with another table field

vaibhav2015

Registered User.
Local time
Today, 16:31
Joined
Sep 15, 2015
Messages
25
Hi,
I have two tables and I want to validate the material column in two tables.
Material field type is "Short text"

table1 [ACT_Import_Table]![Material]
table2 [ACT_Ext_Table]![Material].

I want to compare above two tables, I will enter materials in "ACT_Ext_Table" If that Material exist in "ACT_Import_Table", I want to run query1 and If materials is not exist in "ACT_Import_Table" I will run another query2.
Can you please advice how I can use VBA codes to run above macro.
 
Combine the tables into one and add a field to differentiate Ext from Import.
 
I try to use Dcount function but If condition always go to else option. I want to check material column in table "ACT_Sub_table". can you please advice what changes I have to correct in below code.

If Nz(DCount("*", "ACT_Import_Ext_Table", "[Material] = '" & Me.Material & "'"), 0) > 0 Then

MsgBox "run update"
DoCmd.OpenQuery "Act_Ext_Update_Import_Table"

Else

MsgBox " run append"

DoCmd.OpenQuery "ACT_Ext_Append_Import_Table"
 
I try to use Dcount function but If condition always go to else option. I want to check material column in table "ACT_Sub_table". can you please advice what changes I have to correct in below code.

If Nz(DCount("*", "ACT_Import_Ext_Table", "[Material] = '" & Me.Material & "'"), 0) > 0 Then

Your syntax appears to be correct.

Maybe you just have the wrong tablename? See bolded names.
 

Users who are viewing this thread

Back
Top Bottom