Restricting Data Between Tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm looking for code that will allow me to restrict inputting data in one
table if data is not found in another table.

Tables:
tblParts.PartNo
tblMasterPartList.PartNo

I need to have the tblParts.PartNo field check the tblMasterPartList.PartNo
field to make sure there is an existing part number in the
tblMasterPartList.PartNo.And, if yes, allow an entry into the tblParts.PartNo
field/table. If there is no matching part number found in the
tblMasterPartList.PartNo field, I need to return a message that says, "go see
Mark for permission".

I'm fairly new at programming, so if you can provide the code I'd be
greatful. Or fi you know someplace where I could find the code to do this.
 
Nanette said:
I'm looking for code that will allow me to restrict inputting data in one
table if data is not found in another table.

Tables:
tblParts.PartNo
tblMasterPartList.PartNo

I need to have the tblParts.PartNo field check the tblMasterPartList.PartNo
field to make sure there is an existing part number in the
tblMasterPartList.PartNo.And, if yes, allow an entry into the tblParts.PartNo
field/table. If there is no matching part number found in the
tblMasterPartList.PartNo field, I need to return a message that says, "go see
Mark for permission".


You need to use a form to display/add/edit the records in
tblParts. Then you could use the PartNo text box's
BeforeUpdateEvent:

If DCount("*", "tblMasterPartList", _
"PartNo=" & Me.txtPartNo) = 0 Then
Me.txtPartNo.Undo
Cancel = True
MsgBox "go see Mark for permission"
End If
 
Back
Top