Solved

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

Posted on 2014-01-27
3
325 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
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…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
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…

762 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

8 Experts available now in Live!

Get 1:1 Help Now