Solved

Add Not In List data

Posted on 2006-07-04
6
293 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
[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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
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…

738 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