Prev: looping thru a continous form
Next: Closing Access While Form Is In Print Preview Does Not Trigger Form Unload Event
From: mapmaker on 4 Jun 2010 16:14 Hi, I have a form where if a (vendor) combo box field is "null", a msgbox pops up asking the user to choose a vendor. After a vendor is chosen, an order form pops up with the vendor info populated. All of this is coded on a button: if isnull(forms!frmInventory.vendor) then msgbox "Please choose a Vendor", forms!frmInventory.vendor.SetFocus *****more code here***** end if forms!frmInventory.vendor.value = vendor docmd.openform "frmOrders"... vendor = forms!frmInventory.vendor.value forms!frmOrders.vendor.SetFocus forms!frmOrders.vendor.text = vendor what code do I use in the '*****more code here*****' to select a value in the combo box, then return to the frmOrders? I've tried OnDirty, ItemsSelected, AfterUpdate, and others.... Novice to this stuff.....please be gentle :) Sal
From: Marshall Barton on 5 Jun 2010 07:57 mapmaker wrote: >I have a form where if a (vendor) combo box field is "null", a msgbox pops up >asking the user to choose a vendor. After a vendor is chosen, an order form >pops up with the vendor info populated. >All of this is coded on a button: > >if isnull(forms!frmInventory.vendor) then > msgbox "Please choose a Vendor", > forms!frmInventory.vendor.SetFocus > *****more code here***** >end if > >forms!frmInventory.vendor.value = vendor >docmd.openform "frmOrders"... >vendor = forms!frmInventory.vendor.value >forms!frmOrders.vendor.SetFocus >forms!frmOrders.vendor.text = vendor > >what code do I use in the '*****more code here*****' to select a value in the >combo box, then return to the frmOrders? I don't follow all that, but it seems like you don't need to do anything there. You just want the code to exit so the user can select a vendor in the combo box. When a user has been selected, then open the orders form with a filter to the selected vendor. The code might be something like: if isnull(Me.vendor) then msgbox "Please choose a Vendor", Me.vendor.SetFocus Exit Sub end if docmd.openform "frmOrders", , ,"Vendor=" & Me.Vendor In the future, please use Copy/Paste when you post an expression, VBA code or a query's SQL statement so we can avoid going back and forth chasing typos introduced by retyping. -- Marsh MVP [MS Access]
From: mapmaker via AccessMonster.com on 7 Jun 2010 08:08
Thanks Marshall, I'll give it a try and I'll copy/paste next time. Much appreciated! Sal Marshall Barton wrote: >>I have a form where if a (vendor) combo box field is "null", a msgbox pops up >>asking the user to choose a vendor. After a vendor is chosen, an order form >[quoted text clipped - 15 lines] >>what code do I use in the '*****more code here*****' to select a value in the >>combo box, then return to the frmOrders? > >I don't follow all that, but it seems like you don't need to >do anything there. You just want the code to exit so the >user can select a vendor in the combo box. > >When a user has been selected, then open the orders form >with a filter to the selected vendor. The code might be >something like: > >if isnull(Me.vendor) then > msgbox "Please choose a Vendor", > Me.vendor.SetFocus > Exit Sub >end if > >docmd.openform "frmOrders", , ,"Vendor=" & Me.Vendor > >In the future, please use Copy/Paste when you post an >expression, VBA code or a query's SQL statement so we can >avoid going back and forth chasing typos introduced by >retyping. > -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/201006/1 |