Solved

Add Not In List data

Posted on 2006-07-04
6
256 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
Comment Utility
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
Comment Utility
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
Comment Utility
I apologize - mbizup just posted what i did - I agree with that answer
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 61

Expert Comment

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

Author Comment

by:zubin6220
Comment Utility
Thanks for the quick response.  Works great!
0
 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Glad I could help :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

728 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now