That makes more sense! As usual, there are several ways to do this. Because 'descriptions' tend to be long, I'll describe a method to return the
description Field even if it is defined as a
Memo Field (or
Long Text Field, in the latest versions of Access.)
Where
- txtStatus is the Form Textbox where the user enters the status designation (i.e. 01, 02, 03, etc)
- txtStatusDescription is the Form Textbox that holds the status description
- Status is the Table Field that holds the status designation
- StatusDescription is the Table Field that holds the status description
- StatusTableName is the actual name of the Table that holds the status and status description
Code:
Private Sub txtStatus_AfterUpdate()
Me.txtStatusDescription = Nz(DLookup("StatusDescription", "ActualTableName", "Status ='" & Me.txtStatus & "'"), "Status Does Not Exist!")
End Sub
When the user enters the
Status and moves off of the
Textbox, the
Description Textbox will be populated with the
appropriate Description. If the
Status does not exist in the
Table, the
Description Textbox will display the message
Status Does Not Exist!
You might want to use
Conditional Formatting to change the
Fore Color or
Back Color to another color, if the
Description Textbox equals to '
Status Does Not Exist!,' as a warning to your users.
Linq
;0)>