I have tried my hand at the VBA code to fix this, but I admit I am a novice in VBA. Hopefully one of you can help me out. Here is what I want to do:
I have a form that only has command buttons that represent pieces of equipment in a laboratory floor plan layout (i.e. one button represents one piece of equipment in that laboratory). I want to be able to click on a certain equipment's command button and launch a data entry form AND have the data entry form filtered to the exact piece of equipment.
I figured the easiest way would be to add an "ApplyFilter" line of code for each command button in my VBA console, but I am not sure how to tell VBA to apply the filter to the form the command button is supposed to open. Right now I believe VBA is applying the filter to the form with all the command buttons on it, so it isn't helping me out.
Here is the code from one command button (for equipment # IN-1021), I want that particular command button (IN_1021_Datasheet) to open Form "Instruments TRM" and filter that opened form for "IN-1021" in the "Unique Tag" control field:
I have a form that only has command buttons that represent pieces of equipment in a laboratory floor plan layout (i.e. one button represents one piece of equipment in that laboratory). I want to be able to click on a certain equipment's command button and launch a data entry form AND have the data entry form filtered to the exact piece of equipment.
I figured the easiest way would be to add an "ApplyFilter" line of code for each command button in my VBA console, but I am not sure how to tell VBA to apply the filter to the form the command button is supposed to open. Right now I believe VBA is applying the filter to the form with all the command buttons on it, so it isn't helping me out.
Here is the code from one command button (for equipment # IN-1021), I want that particular command button (IN_1021_Datasheet) to open Form "Instruments TRM" and filter that opened form for "IN-1021" in the "Unique Tag" control field:
Code:
Private Sub IN_1021_Datasheet_Click()
On Error GoTo Err_IN_1021_Datasheet_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Instruments TRM"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.ApplyFilter "Forms!Instruments TRM![Unique Tag]" = "IN-1021"
Exit_IN_1021_Datasheet_Click:
Exit Sub
Err_IN_1021_Datasheet_Click:
MsgBox Err.Description
Resume Exit_IN_1021_Datasheet_Click
End Sub