Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Table Info to Form

Status
Not open for further replies.

LadyDev

Programmer
Jan 29, 2003
86
US
I want to use a form as a popup based on selection from a listbox. I already have it working, but I have to create a different form for each selection. Can I, based on the below table, pass the parameters of LgDesc and SubMenuName to a single form and have that form change based on listbox selection? If so, how do I do that in code? Website? Pass thread dealing with this?

I have a table: tblMenuItems

LgID
LgDesc
MenuName
SubMenuName
DirName
SortOrder

This is the code on the form for the listbox:

Option Compare Text
Option Explicit


Private Sub lstMain_Click()

Me.lstSubDirectory.Requery
DoCmd.OpenForm "frmpopup"

End Sub

Private Sub lstSubDirectory_Click()

DoCmd.OpenForm "xfrmGrid", acNormal, , , , , _
DLookup("DirName", "tblMenuItems", _
"MenuName = " & Chr$(34) & Me.lstSubDirectory & Chr$(34)) & Me.lstSubDirectory & "\"


 
You can use the openArgs argument of the openform method to pass a parameter to the form that you are opening. In the form open event you can then use the parameter value for whatever purpose you need. It's a little trickier to pass multiple parameters but you can string them together with a delimeter of your choice and then parse them in the form open event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top