473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Notinlist Event

mal
Have tried numerous ideas from the group to solve this one. It is such
a simple example that it should be straightforward ! I just want to
add a new item to a combo that has data from a file, by typing in the
new value , adding to the file and the requerying to get the new valus
in the list. i.e. a data entry and data display combo box.
I select an item from cmb1 and cmb2. I focus on cmb3 and the user can
type a new value. This then adds to the underlying table used by both
cmb1, cmb2 and cmb3. All works fine except for the not in list error
and the system repeatedly waits with the combo dropped down, for an
item to be selected. If I keep changing the focus elsewhere, the
system, just goes back and repeats my query. If, on response to my
query, I accept and add a second time then all works OK except I now
have 2 records on the database.
Why is it adding to the table, but still requesting to select from the
drop down list ?
Why does it seem to be OK the second time ?
If I do something else after the second time and then look at the drop
down, sure enough there are 2 records there. I think this is because I
have a requery in the GetFocus event. My problem is why it needs me to
select Yes to my user prompt twice !!!
Any Ideas ?
Thanks
Private Sub cmb3_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
Dim rst As Variant
Dim db As database
' this makes no difference - DoCmd.SetWarnings False
' the next few lines get values from other cmb to display the full
record details
' of the record to be added.
' cmb1 has limit to list = yes and must be in the list
' cmb2 has limit to list = no and can have any value entered
' it is only when this third field is entered that
' prompt should occur and the record added to the data file
' In prcatice the record is added Ok but the error message
' The text you entered isn't an item in the list
strMsg = cmb1.Value & " " & cmb2.Value & " "
strMsg = strMsg & NewData & " is not in the list. "
strMsg = strMsg & "Would you like to add it?"
' The following MSGBox is fine
If MsgBox(strMsg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
Else
Response = acDataErrAdded ' or acDataErrcontinue tried
' now add the record - this bit works fine
Set db = OpenDatabase("Mydatabase.mdb")
Set rst = db.OpenRecordset("tblUnderlyingTable",
DB_OPEN_TABLE)
rst.AddNew
rst!FavouriteGroup = MyFavourite ' saved from cmb1.value
rst!TeamCLientName = MyFavouriteTeamClient ' saved from
cmb2.value
rst!GroupName = NewData
rst.Update
rst.Close
' if I quit the system here,
' the record has been added to the table correctly
'
' Other things I've tried -
' this doesn't work........ Me.Refresh
'
' you must save the current record
' before you requery occurs if I include
cmbGroupDescription.Requery
'
' makes no difference cmbGroupDescription = Null
' makes no difference cmbGroupDescription.Requery
'
' this makes no difference - DoCmd.SetWarnings True
End If
End Sub
Nov 13 '05 #1
0 1076

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pieter Linden | last post by:
Just got done reading some of ADH2000 about comboboxes and the NotInList event... Doesn't look like it's possible to tweak the behavior of this so that I can have a non-text bound column, can I?...
5
by: David Deacon | last post by:
Hi i have the following code in a CustomerID field if the user enters a notinlist customer then they should dbl click to open the customer form However this error occurs "You tried to assign a...
2
by: whilstiwait | last post by:
I have a form containing a number of unbound combo boxes in three columns. Each column has boxes named "aaaa0", "aaaa1", etc. Using syntax like: With Forms(Me.Form.Name).Controls("txtTechnology"...
4
by: CAD Fiend | last post by:
Hello, I have a combo box (cmbFirstName) on a form that is hitting a query (qryFirstName) and then putting that selected (or typed by user) value to the table field (name FirstName) on the table...
11
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
3
by: Bryan | last post by:
I have a listbox that the user is able to add items to through and SQL statement that is run on the NotInList event. At the end of the event, I set Response = acDataErrAdded, telling access that...
7
by: Bryan | last post by:
I am trying to allow the user to add an item to a list if it is not found in a combobox. When the NotInList event is triggered I run a function "AddItem" that has a custom dialog box to add an...
1
imrosie
by: imrosie | last post by:
Hello (from Rosie the newbie), I recently got help with a wonderful event to perform this from 'thescripts'...it recognizes that a name is not in the list an allows for (after parsing first and...
2
FireMedic
by: FireMedic | last post by:
Hello all, I am creating an application that has an equipment inventory and maintenance form that has numerous subforms that are displayed depending on the category of equipment selected. I have...
6
by: Volker Neurath | last post by:
Hi all, I have a Problem with combobox-property "NotInList" and an unbound Form. The situation: On my main form i have three comboboxes for data-exchange (here: Names of distributor,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.