Solved

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

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

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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.

749 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