?
Solved

Add Not In List data

Posted on 2006-07-04
6
Medium Priority
?
303 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 1000 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
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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 Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

770 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