Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Not in list

Status
Not open for further replies.

fileman1

Technical User
Feb 7, 2013
152
GB
I am having so many problems with Access, using the not in list event.
I have tried so many ways of doing it but just kept getting repeated notices of do you want to add etc etc etc and then finally getting the record could not be saved this time, despite it being saved.

Then I found some code that worked in someone else's download. It had all the same references as I had in Access, and worked. However using the code in my Access it failed. However when I imported the example form into my db, my form started working. However it's stopped now. So I re imported the demo example in again and it worked for a few times, and then now fails again.

How can I check my version of Access is ok? I have reinstalled twice with no difference.

Code:
Private Sub Combo3_NotInList(NewData As String, Response As Integer)
Dim strsql As String, x As Integer

x = MsgBox("Do you want to add this Keyword to the list?", vbYesNo)
If x = vbYes Then
    strsql = "Insert Into KeywordTable ([Keyword]) values ('" & NewData & "')"
    CurrentDb.Execute strsql, dbFailOnError
    Response = acDataErrAdded
Else
    Response = acDataErrContinue
End If
End Sub
 
I have uninstalled Office 2010 and re installed. Still same problem. I just tried removing the code in the Not In List event which does the saving, ie just keeping the "Do you want to save Y/N", but that just went into a continous asking do you want to save mode, and even on saying No would not let go.

So in design mode I tried removed the Not In List code, and tried to set the Limit to List to No and got a message box

"Microsoft Access can't set the limit to list property to No right now.

The first visible column, which is determined by the ColumnWidths property, isn't equal to the bound column. Adjust the ColumnWidths property first, and then set the Limit to List property."

My Combo
List Rowsource :
SELECT KeywordTable.KeywordID, KeywordTable.Keyword
FROM KeywordTable;

Bound Column = 1
Column Count = 2
Column Widths = 0";1"

Can someone tell me why this is all happening. Spent all day on what should be a simple task Thanks
 
I am having so many problems with Access, using the not in list event
I probably know as much about coding access as anyone, and this still kicks my butt especially if you want to do some detail verification of the data you plan to add to the list. So I never ever use this event and I do not really care for the methodology anyways. Normally if I want to have a combo that you can add to the list I have an icon (plus sign) next to my combo. Or I can use a double click event. This pops open a dialog form to add a record.
 
Thanks both. If I say I want to add to the list it adds it, but when I move to another control it asks again and again. If I say no it adds it, and still asks afterwards did I want to save. I wish there was a contact with Microsoft to verify my software is okay. I tried it on my other PC having the same installation and that does the same. The strange thing is if I import someone else's form with exact coding which I had copied, and the same references, their form works in this event.

I am taking out the use of NotInList and adding another way, but thanks both.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top