Solved

Add Not In List data

Posted on 2006-07-04
6
300 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

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!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

707 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