Solved open different forms as per the selection in the list box

ahmad_rmh

Member
Local time
Today, 14:43
Joined
Jun 26, 2022
Messages
243
I am trying to open different forms as per the selection in the list box. I have tried this which opens the same form on double click.

Code:
DoCmd.OpenForm "frmItemsDetail", acNormal, , "[MasterTablesPK] =1 " & Me.DynamicList.Column(0)

I want to open different forms as per the selection.

for example:

MasterTablesPK=1 , Items List Form
MasterTablesPK=2, Suppliers Form
MasterTablesPK=3, Locations Form

How to get this solution.
 
An approach with a bit of systematics:
Code:
Dim sFormName As String
Select Case Me.lstSelection
   Case 1
      sFormName = "frmA1"
   Case 2
      sFormName = "frmBXY"
   Case 3
      sFormName = "frmByeBye"
   CaseElse
      ' unexpected happened
End Select

DoCmd.OpenForm sFormName
 
based the Rowsource of your listbox to a table, on the demo, it is FormNamesT table.
much systematic, i guess.
 

Attachments

thanks, both works, but more systematic with short code and proper management of master forms table as described by arnel.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom