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

Problems imposing constraints on a form

Status
Not open for further replies.

DanEaton

Technical User
Jun 24, 2002
60
CA
I have a data entry form. It has many fields describing a catalog and how it is filed. Many of the catalogs we receive are in different formats. There are catalogs, cd's and what we call "datasheets". Datasheets (as the name suggests) are simply single, or groups of sheets with product-specific data. When we file these datasheets, we do so alphabetically within binders corresponding to the vendor name on their cover. In other words, we have binders for every letter of the alphabet. On my form, I have a list box that constrains the user to select from either of these three formats. I have it so that if datasheet is selected, the focus jumps to the binder combo box. One problem I have noticed is, when people are entering in many catalogs, datasheets and cd's they may forget to choose the binder that it's in if datasheet is the format. This screws up our labels, resulting in mis-filing. I can't make the binder field required because it isn't; catalogs would not fit in this category. I do, however, want to make them required if datasheet was selected as the format. I want a msgbox defined by myself to warn users if they overlook the binder field, and I want the required property set to true if the datasheet is selected. I've written some code already, but nothing has worked (not that I'm exceptionally good at VBA). Anyway, I'll show you what I tried, I won't be surprised if it's got bad syntax or bad logic. I would love some help. thanks

(after update event)

Code:
Dim Msg, Style
Me!cboBinder.Required = True
    If Me!cboBinder = Null Then
        
        Msg = "It is required that you enter which binder the datasheet will be filed under!"
        Style = vbInformation
        
        If MsgBox(Msg, Style, "Binder Requirement") = vbOK Then
        
            Me!cboBinder.SetFocus
            
        End If
        
    End If

Dan Eaton
deaton@caemachinery.com
 
Just a suggestion - If you have the Vendor name, I presume the first character of the name should match the binder?

If so - why not select the binder yourself in code?

AS regards your code

Can you tell us what is not working
Does it run the event at all
Does it display the message box
Does it set the focus to the cbobinder object


Maybe the cbobinder is not null maybe it is ""

Let us know how you get on

Paul
 
Thanks for replying Paul. The reason that the binder is not an auto-fill is that I must leave room for expansion. Many letters are used to often to warrant only one binder, so A leads to A-1, A-2...etc. I have since developed some code to fix the problem, but thank you for your reply. Dan Eaton
deaton@caemachinery.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top