Solved

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

Posted on 2014-01-27
3
327 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
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…

773 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