Basing criteria on a variable when opening a subform

B

BBanks

I have a table that has an field for unique IDs, one for building, one for
categories of potential problems, and one for a description.

The category field is a combo box that can be good/bad and if it is "bad" a
subform pops up asking for the description of why it is bad. It uses the
unique ID to keep the description specifict to its building
--- I think I have it up to this point ---
this is the code I have

Private Sub CatA_AfterUpdate()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "SbFrm_CatA"

If Me![CatA] = "Bad" Then
stLinkCriteria = "[ID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
End If
End Sub

My problem is that in the interest of time, I don't want to make a separate
form for every category (I have 150 of them) so I can put a corresponding
description for that category. I would rather have a dynamic form that
records which ever category was selected on the main form as a variable and
then based on that information, inserts the appropriate textbox into the
subform that matches the selected category.
 
Top