Solved

How return user to input box

Posted on 2013-01-19
4
262 Views
Last Modified: 2015-01-05
On a form I have a combobox named "cboPart_No". The after update event does this:

    'Display message box to warn user that excess inventory exists for this part number and allow for applied inventory qty ...
     If DSum("[Qty]", "tblFinGoods", "[PartN] = '" & Me.cboPart_No & "'") > 0 Then
        txtAppliedInvQty = InputBox("Excess inventory exists for this part number. Qty = " & (DSum("[Qty]", "tblFinGoods", "[PartN] = '" & Me.cboPart_No & "'") & " .  Enter the qty you want to apply to this order: (Be careful to enter the exact amount)"))
   
    'Alert if applied qty is greater than available qty...
        If Me.txtAppliedInvQty > (DSum("[Qty]", "tblFinGoods", "[PartN] = '" & Me.cboPart_No & "'")) Then
            MsgBox "You have entered a quantity greater than the available quantity.  Please correct the entry."
        End If

If the user enters a value greater than the DSum value I want them to be returned to the combobox AFTER the message telling them they haver a bad number, (the 2nd if...then statement), with the combobox blanked out.

What code do I need to do this?

--Steve
0
Comment
Question by:SteveL13
4 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 38796572
You say that this code is in the afterupdate event procedure of the Part_no combo?

It looks like it ought to be attached to the quantity field?

And you want to go back to the Part_no combo if the quantity is wrong?

Can you just confirm this please.
0
 

Author Comment

by:SteveL13
ID: 38796859
This is correct.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 38797376
I'm on my iPad so I'm going to abbreviate this

If dsum() >0 then

    Do

        X = input box

        If x <= dsum () then exit do

        Msgbox

Loop
0
 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 500 total points
ID: 38798779
Just set the focus back to the combo box, like this:

Me![cboPart_no].SetFocus
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now