Solved

have a window pop up based on a value supplied in a lookup on a form

Posted on 2014-01-27
3
329 Views
Last Modified: 2014-02-12
I have a form in ACcess that the user selects a value, if the user selects a specific value from a combobox I would like a message box to appear asking the user to supply an Invoice Number.  Then want that invoice number to be stored in the record source of the form.

the combo box is  combo42, the value they would select to cause the Message Boxo to be displayed  would be  "MCMC"
FIeld in the record source would be "MCMCINVOICENO"
0
Comment
Question by:seamus9909
3 Comments
 
LVL 10

Expert Comment

by:Gozreh
ID: 39812868
Private Sub combo42_AfterUpdate()
   Dim Result As String
   If Me.combo42 = "MCMC" Then
      Result = InputBox("Please enter the invoice number")
      Me!MCMCINVOICENO = Result
   End If
End Sub

Open in new window

you can also validate the result it should not be null or what you need
0
 
LVL 30

Expert Comment

by:hnasr
ID: 39812888
Compare with:
    If f2 = 11 Then
        f2 = InputBox("Enter value", "Value for field")
    End If

edit: Previous comment is fine. Can be edited to check for accepted results.
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 500 total points
ID: 39812950
I would recommend that you put the bound field MCMCInvoiceNo in a textbox on your form.   Disable that control, and then use the AfterUpdate event of the combo box to change enable/disable that control.

Private Sub cboYourComboName_AfterUpdate

    me.txt_MCMCInvoiceNo.Enabled = (me.cboYourComboName & "" = "MCMC")

End Sub

Then, you would also need to put that line in the Form_Current event, so that it is enabled when you move back to that record.

And finally, in the BeforeUpdate event of your form, you would need to check to make sure that if cboYourComboName = MCMC that the value in txt_MCMCInvoiceNo is not NULL.

Private Sub Form_BeforeUpdate(Cancel as integer)

    if me.cboYourComboName.Enabled = True and me.txt_MCMCInvoiceNo & "" = "" Then
        msgbox "if combo name is 'MCMC' then you must fillin the MCMC Invoice #"
        cancel = true
    end if

end sub
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

837 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