combo box troubles

M

mapmaker

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
 
M

Marshall Barton

mapmaker said:
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.
 
M

mapmaker via AccessMonster.com

Thanks Marshall, I'll give it a try and I'll copy/paste next time. Much
appreciated!
Sal

Marshall said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top