Rick Stanich
King and Supreme Ruler
- Local time
- Today, 03:04
- Joined
- May 13, 2009
- Messages
- 93
I have four textbox's, the first sets a value compared to a table. If the value entered match's a value in the table the user advances to the next textbox. The value entered in the next textbox needs be evaluated to the relationship of the previous table.
Textbox1 = Part Number
TextBox2 = Part Revision
This code looks at the table for part number.
Textbox2 value is to be evaluated by th erelationship of textbox1 value and not the entire table for Part Revision.
Strikingly similar eh!?
I do not know how to write the code to set the relationship to tblParts from tblPartRev.
As is, tblPartRev evaluates the entered value to its entire set of data regardless of tblParts.
This making sense? (Its killing me).
(Code samples courtesy of RuralGuy)
Textbox1 = Part Number
TextBox2 = Part Revision
This code looks at the table for part number.
Code:
Private Sub sPartNumber_BeforeUpdate(Cancel As Integer)
If DCount("*", "tblParts", "txtPartNo = '" & Me.sPartNumber.Text & "'") Then
'MsgBox "Match found" 'for testing
'create link to next textbox here?
Else
Cancel = False
MsgBox "The part number doesn't exist in this database. Please re-enter the part number."
'return focus to sPartNumber textbox
End If
End Sub
Code:
Private Sub sPartRev_BeforeUpdate(Cancel As Integer)
If DCount("*", "tblPartRev", "txtRev = '" & Me.sPartRev.Text & "'") Then
'MsgBox "Match found" 'for testing
Else
Cancel = False
MsgBox "The revision level doesn't match part numbers in this database. Please re-enter the revision level."
'return focus to sPartRev textbox
End If
End Sub
I do not know how to write the code to set the relationship to tblParts from tblPartRev.
As is, tblPartRev evaluates the entered value to its entire set of data regardless of tblParts.
This making sense? (Its killing me).
(Code samples courtesy of RuralGuy)