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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing value from listbox to a textbox in other form 1

Status
Not open for further replies.

davyre

Programmer
Oct 3, 2012
197
AU
Hi,

I got this listbox that has many records. What I want is to pass the value of the selected record to another form that triggered after I pressed a button in the form that has the listbox. How can I do that? Can I do it with query? Or can I do it by storing a global variable? Or any simplistic solution? Thanks

heres the listbox, after I select one of the records in the listbox and click the update unit button, I want the selected unitID to be passed to...
listbox.jpg


this textbox with label unitID in another form
textbox.jpg


any suggestion/solution? Thanks
 
In the update unit button Click event procedure:
Forms![another form]!unitID = Me![list box]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
thanks for the reply, but I got the error saying MSAccess could not find the form that I refer to. Should I declare dim anotherform as form first? And about Me![listbox], do it automatically refer to the unitID field? because the listbox is populated from a query that has many fields (unitID is among them).
 
What is the name of the another form ?
What is the SQL code of the RowSource of the list box ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Code:
SELECT TblOrderUnit.OrderunitID, TblOrderUnit.OrderID, TblOrderUnit.UnitID, TblUnits.UnitDescription, TblOrderUnit.QtyOrdered, TblOrderUnit.ModelID, TblModel.ModelDesc, TblOrderUnit.ETD, TblOrderUnit.UnitDeliveryDate, TblOrderUnit.Status
FROM (TblModel INNER JOIN TblUnits ON TblModel.ModelID = TblUnits.ModelID) INNER JOIN TblOrderUnit ON TblUnits.UnitID = TblOrderUnit.UnitID
WHERE (((TblOrderUnit.OrderID)=[forms]![FRMOrder1]![orderid]))
ORDER BY TblOrderUnit.OrderID;

the form is now okay, but I cannot get correct value from Me![ListOrderID]. It passes value of OrderunitID while what I want is the UnitID
I tried Me![ListOrderID]![UnitID] but it shows error. How can I get the UnitID?
 
Me![ListOrderID].Column(2)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top