473,394 Members | 1,714 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,394 software developers and data experts.

NotInList making me crazy(er)

FireMedic
Hello all,
Having a bit of grief with a NotInList code block that has quit working properly.
I have set it as a public sub in a module so I can use it in multiple forms. I t worked ok in the form module but seems to be a bit glitchy in the public mode.

The new value does not seem to be taking and in spite of "acdataAdded" it continues to pop up the standard warning telling the user to pick an item from the list after the second message box closes. Ultimately the data doesnt get added.
Combo box source is:
Expand|Select|Wrap|Line Numbers
  1. SELECT [tbl_Manufacturers].[MfgrID], [tbl_Manufacturers].[MfgrName] FROM tbl_Manufacturers ORDER BY [tbl_Manufacturers].[MfgrName]; 
Limit To List is set to - Yes

Code is As Follows:
Expand|Select|Wrap|Line Numbers
  1. Public Sub MfgNIL()
  2.  
  3. On Error GoTo MfgNIL_Err
  4.     Dim IntAnswer As Integer
  5.     Dim StrSql As String
  6.  
  7.     IntAnswer = MsgBox("The Manufacturer " & Chr(34) & (NewData) & _
  8.         Chr(34) & " is not currently listed." & vbCrLf & _
  9.         "Would you like to add it to the list now?" _
  10.         , vbQuestion + vbYesNo, "I-TEAM Utilities")
  11.  
  12.       If IntAnswer = vbYes Then
  13.         StrSql = "INSERT INTO tbl_Manufacturers([MfgrName]) " & _
  14.                  "VALUES ('" & NewData & "');"
  15.         DoCmd.SetWarnings False
  16.         DoCmd.RunSQL StrSql
  17.         DoCmd.SetWarnings True
  18.         Response = acDataErrAdded
  19.  
  20.  
  21.         MsgBox "The new Manufacturer has been added to the list." & _
  22.         " Please remember to enter remaining contact information" & vbCrLf & _
  23.         "as soon as possible to ensure complete records" & vbCrLf & _
  24.         "Use the 'Find' control on the 'Manufacturers' form to locate this Manufacturer." _
  25.             , vbInformation, "I-TEAM Utilities"
  26.  
  27. Else
  28.         MsgBox "Please choose a Manufacturer from the list." _
  29.             , vbInformation, "I-TEAM Utilities"
  30.         Response = acDataErrContinue
  31.  
  32.     End If
  33.  
  34. MfgNIL_Exit:
  35.     Exit Sub
  36. MfgNIL_Err:
  37.     MsgBox Err.Description, vbCritical, "Error"
  38.     Resume MfgNIL_Exit
  39. End Sub
It is notable that the (New Data) is not appearing in the first message box string when it displays. It shows empty quotes instead where the new Mfg name should appear.

This ones been driving me crazier then I normally am. If someone could point out my blind spot it would be much appreciated.
Thanks in advance
Apr 13 '08 #1
12 1768
Forgot to mention that the visible column in the cbo box is a text field while the bound column is an autonumber ID field.

Thanks again
Apr 13 '08 #2
ADezii
8,834 Expert 8TB
Hello all,
Having a bit of grief with a NotInList code block that has quit working properly.
I have set it as a public sub in a module so I can use it in multiple forms. I t worked ok in the form module but seems to be a bit glitchy in the public mode.

The new value does not seem to be taking and in spite of "acdataAdded" it continues to pop up the standard warning telling the user to pick an item from the list after the second message box closes. Ultimately the data doesnt get added.
Combo box source is:
Expand|Select|Wrap|Line Numbers
  1. SELECT [tbl_Manufacturers].[MfgrID], [tbl_Manufacturers].[MfgrName] FROM tbl_Manufacturers ORDER BY [tbl_Manufacturers].[MfgrName]; 
Limit To List is set to - Yes

Code is As Follows:
Expand|Select|Wrap|Line Numbers
  1. Public Sub MfgNIL()
  2.  
  3. On Error GoTo MfgNIL_Err
  4.     Dim IntAnswer As Integer
  5.     Dim StrSql As String
  6.  
  7.     IntAnswer = MsgBox("The Manufacturer " & Chr(34) & (NewData) & _
  8.         Chr(34) & " is not currently listed." & vbCrLf & _
  9.         "Would you like to add it to the list now?" _
  10.         , vbQuestion + vbYesNo, "I-TEAM Utilities")
  11.  
  12.       If IntAnswer = vbYes Then
  13.         StrSql = "INSERT INTO tbl_Manufacturers([MfgrName]) " & _
  14.                  "VALUES ('" & NewData & "');"
  15.         DoCmd.SetWarnings False
  16.         DoCmd.RunSQL StrSql
  17.         DoCmd.SetWarnings True
  18.         Response = acDataErrAdded
  19.  
  20.  
  21.         MsgBox "The new Manufacturer has been added to the list." & _
  22.         " Please remember to enter remaining contact information" & vbCrLf & _
  23.         "as soon as possible to ensure complete records" & vbCrLf & _
  24.         "Use the 'Find' control on the 'Manufacturers' form to locate this Manufacturer." _
  25.             , vbInformation, "I-TEAM Utilities"
  26.  
  27. Else
  28.         MsgBox "Please choose a Manufacturer from the list." _
  29.             , vbInformation, "I-TEAM Utilities"
  30.         Response = acDataErrContinue
  31.  
  32.     End If
  33.  
  34. MfgNIL_Exit:
  35.     Exit Sub
  36. MfgNIL_Err:
  37.     MsgBox Err.Description, vbCritical, "Error"
  38.     Resume MfgNIL_Exit
  39. End Sub
It is notable that the (New Data) is not appearing in the first message box string when it displays. It shows empty quotes instead where the new Mfg name should appear.

This ones been driving me crazier then I normally am. If someone could point out my blind spot it would be much appreciated.
Thanks in advance
Your Not-In-List code block is meant to be fired from the NotInList() Event of a Combo Box, and not in a Public Procedure. If you wish to make it somewhat portable and run it from a Public Sub-Routine, pass NewData as an Argument to the Sub-Routine, where it can now be accessed, as in:
Expand|Select|Wrap|Line Numbers
  1. Call MfgNIL(NewData)
To the best of my knowledge, you will not have control over the Response Parameter, since it is out of context. This means you will not be able to suppress the Default Access Error Message when an Item is entered when it is not in the List (LimitToList = True). You will also have to manually Requery the Combo Box since Response = acDataErrAdded will now be meaningless. You are probably better off leaving the code in the Event for which it was dsesigned.
Apr 13 '08 #3
Your Not-In-List code block is meant to be fired from the NotInList() Event of a Combo Box, and not in a Public Procedure. If you wish to make it somewhat portable and run it from a Public Sub-Routine, pass NewData as an Argument to the Sub-Routine, where it can now be accessed, as in:
Expand|Select|Wrap|Line Numbers
  1. Call MfgNIL(NewData)
To the best of my knowledge, you will not have control over the Response Parameter, since it is out of context. This means you will not be able to suppress the Default Access Error Message when an Item is entered when it is not in the List (LimitToList = True). You will also have to manually Requery the Combo Box since Response = acDataErrAdded will now be meaningless. You are probably better off leaving the code in the Event for which it was dsesigned.
Sigh... I was afraid of that...There are eighteen subforms and this routine will have to be repeated twice on each .. once for supplier and once for Mfg. Well so be it then. Onward and upward.
I've just gotten back to this after many months of busy work expanding our department responsibilities to include ARFF response at our new on-site aerodrome so I'm still behind the curve on where I left off. Hmmm did someone say commenting your code was a wise idea?

Thanks again ADezzi your assistance is as always much appreciated.
Apr 14 '08 #4
ADezii
8,834 Expert 8TB
Sigh... I was afraid of that...There are eighteen subforms and this routine will have to be repeated twice on each .. once for supplier and once for Mfg. Well so be it then. Onward and upward.
I've just gotten back to this after many months of busy work expanding our department responsibilities to include ARFF response at our new on-site aerodrome so I'm still behind the curve on where I left off. Hmmm did someone say commenting your code was a wise idea?

Thanks again ADezzi your assistance is as always much appreciated.
Always glad to help, especially a Fire Paramedic, since I was a professional Fire Fighter for 32+ years, 15 of which were in a HazMat Unit. Take care.
Apr 14 '08 #5
FishVal
2,653 Expert 2GB
To the best of my knowledge, you will not have control over the Response Parameter, since it is out of context. This means you will not be able to suppress the Default Access Error Message when an Item is entered when it is not in the List (LimitToList = True). You will also have to manually Requery the Combo Box since Response = acDataErrAdded will now be meaningless. You are probably better off leaving the code in the Event for which it was dsesigned.
Hi, all.

What about passing reference to Response variable to MfgNIL() procedure?
BTW ByRef is default for argument declaration, so in example below it is used for illustrative purpose only.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo0_NotInList(NewData As String, Response As Integer)
  2.     .....
  3.     MfgNIL(NewData As String, Response As Integer)
  4.     .....
  5. End Sub
  6.  
Expand|Select|Wrap|Line Numbers
  1. Public Sub MfgNIL(NewData As String, ByRef Response As Integer)
  2.     ....
  3.     Response = acDataErrContinue
  4. End Sub
  5.  
Regards,
Fish
Apr 14 '08 #6
ADezii
8,834 Expert 8TB
Hi, all.

What about passing reference to Response variable to MfgNIL() procedure?
BTW ByRef is default for argument declaration, so in example below it is used for illustrative purpose only.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo0_NotInList(NewData As String, Response As Integer)
  2.     .....
  3.     MfgNIL(NewData As String, Response As Integer)
  4.     .....
  5. End Sub
  6.  
Expand|Select|Wrap|Line Numbers
  1. Public Sub MfgNIL(NewData As String, ByRef Response As Integer)
  2.     ....
  3.     Response = acDataErrContinue
  4. End Sub
  5.  
Regards,
Fish
Excellent point FishVal, and a very interesting one. In the OP's specific circumstance, a Global NotInList Handler would probably be a good idea. One thought, wouldn't the value of Response have to be passed back to the NotInList() Event via the Argument? Another thought, I've never seen this functionality used anywhere except in the NotInList() Event, have you?
Apr 14 '08 #7
FishVal
2,653 Expert 2GB
Excellent point FishVal, and a very interesting one. In the OP's specific circumstance, a Global NotInList Handler would probably be a good idea.
Thanks, ADezii.

One thought, wouldn't the value of Response have to be passed back to the NotInList() Event via the Argument?
Both procedures - event handler and the public procedure, work with just the same variable.

Another thought, I've never seen this functionality used anywhere except in the NotInList() Event, have you?
Do you mean returning values in arguments passed by reference?
If so, then it is more likely to be a usual practice. E.g. all those events with "Cancel" argument. :)

Best regards,
Fish
Apr 14 '08 #8
Well Gents I don't know. I've put it back as a private sub in each subform and it still fails to add the data and requery itself. I get the default notInList warning right after my custom message box and no satisfaction. . Sigh

Expand|Select|Wrap|Line Numbers
  1. Private Sub MfgID_NotInList(NewData As String, Response As Integer)
  2.  
  3. On Error GoTo MfgID_NotInList_Err
  4.     Dim IntAnswer As Integer
  5.     Dim StrSql As String
  6.  
  7.  
  8.     IntAnswer = MsgBox("The Manufacturer " & Chr(34) & (NewData) & _
  9.         Chr(34) & " is not currently listed." & vbCrLf & _
  10.         "Would you like to add it to the list now?" _
  11.         , vbQuestion + vbYesNo, "I-TEAM Utilities")
  12.  
  13.       If IntAnswer = vbYes Then
  14.         StrSql = "INSERT INTO tbl_Manufacturers([MfgrName]) " & _
  15.                  "VALUES ('" & NewData & "');"
  16.         DoCmd.SetWarnings False
  17.         DoCmd.RunSQL StrSql
  18.         DoCmd.SetWarnings True
  19.         Response = acDataErrAdded
  20.  
  21.  
  22.         MsgBox "The new Manufacturer has been added to the list." & _
  23.         " Please remember to enter remaining contact information" & vbCrLf & _
  24.         "as soon as possible to ensure complete records" & vbCrLf & _
  25.         "Use the 'Find' control on the 'Manufacturers' form to locate this Manufacturer." _
  26.             , vbInformation, "I-TEAM Utilities"
  27.  
  28.     Else
  29.         MsgBox "Please choose a Manufacturer from the list." _
  30.             , vbInformation, "I-TEAM Utilities"
  31.         Response = acDataErrContinue
  32.     End If
  33.  
  34. MfgID_NotInList_Exit:
  35.     Exit Sub
  36.  
  37. MfgID_NotInList_Err:
  38.     MsgBox Err.Description, vbCritical, "Error"
  39.     Resume MfgID_NotInList_Exit
  40. End Sub
Apr 20 '08 #9
ADezii
8,834 Expert 8TB
Well Gents I don't know. I've put it back as a private sub in each subform and it still fails to add the data and requery itself. I get the default notInList warning right after my custom message box and no satisfaction. . Sigh

Expand|Select|Wrap|Line Numbers
  1. Private Sub MfgID_NotInList(NewData As String, Response As Integer)
  2.  
  3. On Error GoTo MfgID_NotInList_Err
  4.     Dim IntAnswer As Integer
  5.     Dim StrSql As String
  6.  
  7.  
  8.     IntAnswer = MsgBox("The Manufacturer " & Chr(34) & (NewData) & _
  9.         Chr(34) & " is not currently listed." & vbCrLf & _
  10.         "Would you like to add it to the list now?" _
  11.         , vbQuestion + vbYesNo, "I-TEAM Utilities")
  12.  
  13.       If IntAnswer = vbYes Then
  14.         StrSql = "INSERT INTO tbl_Manufacturers([MfgrName]) " & _
  15.                  "VALUES ('" & NewData & "');"
  16.         DoCmd.SetWarnings False
  17.         DoCmd.RunSQL StrSql
  18.         DoCmd.SetWarnings True
  19.         Response = acDataErrAdded
  20.  
  21.  
  22.         MsgBox "The new Manufacturer has been added to the list." & _
  23.         " Please remember to enter remaining contact information" & vbCrLf & _
  24.         "as soon as possible to ensure complete records" & vbCrLf & _
  25.         "Use the 'Find' control on the 'Manufacturers' form to locate this Manufacturer." _
  26.             , vbInformation, "I-TEAM Utilities"
  27.  
  28.     Else
  29.         MsgBox "Please choose a Manufacturer from the list." _
  30.             , vbInformation, "I-TEAM Utilities"
  31.         Response = acDataErrContinue
  32.     End If
  33.  
  34. MfgID_NotInList_Exit:
  35.     Exit Sub
  36.  
  37. MfgID_NotInList_Err:
  38.     MsgBox Err.Description, vbCritical, "Error"
  39.     Resume MfgID_NotInList_Exit
  40. End Sub
The code should work as stated, could there possibly be a Syntax Error on the Manufacturer Name Field?
Expand|Select|Wrap|Line Numbers
  1. [MfgrName] ==> [MfgName]
Is there any chance of you sending me the Database, or a subset of it, as an E-Mail Attachment so that I may have a look at it? If so, let me know, and I'll send you my E-Mail Address in a Private Message.
Apr 20 '08 #10
sierra7
446 Expert 256MB
Hi
I have noticed recently one of my applications started giving 'Not In List' errors even when the selection WAS in the list, because AutoComplete was not working (i.e. user typed "AL Enter or Tab" in a combo box holding list of metals which usually autocompleted and selected 'Aluminium')

Microsoft windged about ANSI 92 compatability (Yes, it had been changed in Tools>Options>Table/Queries) and how all Select statements for combo boxes had to be "SELECT DISTINCT..."

I'm sorry I don't have time to read the whole blog but it might have a bearing on your probs.

S7
Apr 20 '08 #11
The code should work as stated, could there possibly be a Syntax Error on the Manufacturer Name Field?
Expand|Select|Wrap|Line Numbers
  1. [MfgrName] ==> [MfgName]
Is there any chance of you sending me the Database, or a subset of it, as an E-Mail Attachment so that I may have a look at it? If so, let me know, and I'll send you my E-Mail Address in a Private Message.
Thanks ADezii.
I've parked that block of code for now due to time constraints and have gone to having the Suppliers or Manufacturers form open if the user opts too add the newData. Im using the New data as a variable and inserting it into the name field through the OpenArgs event of the Sup/Mfg forms. I did find that on some of the forms the data was actually added to the table numerous times but was not appearing in the cbo and the Default warning still continued to run after my sub. I'm sure it's just me but I don't have the time to keep troubleshooting this one right now. (I'm referring here to the original code that was giving me grief. The new code I described works fine.)
Apr 22 '08 #12
Hi
I have noticed recently one of my applications started giving 'Not In List' errors even when the selection WAS in the list, because AutoComplete was not working (i.e. user typed "AL Enter or Tab" in a combo box holding list of metals which usually autocompleted and selected 'Aluminium')

Microsoft windged about ANSI 92 compatability (Yes, it had been changed in Tools>Options>Table/Queries) and how all Select statements for combo boxes had to be "SELECT DISTINCT..."

I'm sorry I don't have time to read the whole blog but it might have a bearing on your probs.

S7
Hi sierra7
Thanks for the info. Unfortunately I work in a locked system with the exception of my work station in my office in our main firehall which is an unlocked developer machine. Any changes,installs,updates etc have to be pushed from a central authority and scripted for GI in many cases. This takes a long long time and requires the sacrifice of your firstborn and royal assent if you catch my drift.
Which brings me to my new thread I'm going to start now.
Thanks again.
Apr 22 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: LRW | last post by:
This may be a question more directed to Excel, but I'm using PHP to generate a CSV to be imported into Excel, so maybe the solution is there. So, sorry for crossposting. Anyway, I'm generating a...
2
by: Befuddled | last post by:
Forgive me, this is probably a very simple problem, but it's new to me. When I attempt to make php 4.3.8, it exits, and I believe the relevant message is: libtool: link: cannot find the library...
38
by: Kai Jaeger | last post by:
I am playing with setting font sizes in CSS using em as unit of measurement. All seems to be fine. Even Netscape Navigator shows the characters very similar to IE, what is not the kind if px is...
3
by: windandwaves | last post by:
Hi, I am trying to make errors a bit more meaningful for my users. I am trying to fix error 3201 where there is a missing field in a form. If I do not do any error trapping, then I get ...
1
by: Shawn B. | last post by:
Greetings, I have have been working for almost 18 months on a set of WebControls where some are similar to the ASP.NET standard and well-enhanced while other controls are completely new and...
90
by: Ben Finney | last post by:
Howdy all, How can a (user-defined) class ensure that its instances are immutable, like an int or a tuple, without inheriting from those types? What caveats should be observed in making...
351
by: CBFalconer | last post by:
We often find hidden, and totally unnecessary, assumptions being made in code. The following leans heavily on one particular example, which happens to be in C. However similar things can (and...
0
by: Destini | last post by:
Hi I'm a little confused about something when making a relational model from an ER diagram. Say I have an entity "User" which has it's own primary key and 2 other entities "Child" and "Adult"...
22
by: sheldonlg | last post by:
I am going nuts with IE problems. Here is my problem: Firefox: Shows things properly; javascripts work; etc. etc. IE6: The "onClick" doesn't invoke the javascript that is designated. I know...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.