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
Solved

Add Not In List data

Posted on 2006-07-04
6
285 Views
Last Modified: 2011-08-18
The following works fine except that the EventTypeTable has an additional field of >EventDescription< which of course will not populate.  Since I am adding new data to this table, what needs to be done to include the EventDescription? how can this be entered?  Thanks

Private Sub cboEventType_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Book Category...")
    If i = vbYes Then
      strSQL = "Insert Into EventTypeTable ([EventType]) values ('" & NewData & "')"
            CurrentDb.Execute strSQL, dbFailOnError
            Response = acDataErrAdded
        Else
            Response = acDataErrContinue
    End If
0
Comment
Question by:zubin6220
  • 3
  • 2
6 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 250 total points
ID: 17040063
Try using an InputBox to get a user entered EventDescription:

Private Sub cboEventType_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim i As Integer
Dim Msg As String
Dim Desc as string        '** add this

'Exit this sub if the combo box is cleared
If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not currently in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"

i = MsgBox(Msg, vbQuestion + vbYesNo, "Unknown Book Category...")
    If i = vbYes Then
      Desc = nz(Inputbox("Please Enter the event description"))          '**** Get the user's EventDescription
     '*** Add event description to the Insert statement
      strSQL = "Insert Into EventTypeTable ([EventType], EventDescription) values ('" & NewData & "', '" & Desc & "')"  
            CurrentDb.Execute strSQL, dbFailOnError
            Response = acDataErrAdded
        Else
            Response = acDataErrContinue
    End If
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17040067
if you want to add you could do

strSQL = "Insert Into EventTypeTable ([EventType], [EventDescription]) values ('" & NewData & "', '" & StringWithDescription & "')"

Which would add both event type and event description.
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17040068
I apologize - mbizup just posted what i did - I agree with that answer
0
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.

 
LVL 61

Expert Comment

by:mbizup
ID: 17040081
No problem, Raynard.  I forgot to hit the refresh button before posting a comment tonight, myself.  
btw -- welcome aboard :-)
0
 

Author Comment

by:zubin6220
ID: 17040162
Thanks for the quick response.  Works great!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 17040166
Glad I could help :-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

839 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