Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2014-01-27
3
Medium Priority
?
340 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 31

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 48

Accepted Solution

by:
Dale Fye earned 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

597 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