473,466 Members | 1,396 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

not in list property

lee123
556 Contributor
well this is a tough cookie this property, i just keep on getting a runtime error
with this can anyone tell me what is wrong with this code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PRODUCTCOMBO_NotInList(NewData As String, Response As Integer)
  2.  
  3.     If MSGBOX("THIS ISN'T IN THE LIST,DO YOU WANT TO ADD THIS?", vbYesNo + vbQuestion, "PLEASE RESPOND!") = vbYes Then
  4.         DoCmd.OpenForm "PRODUCTF", DATAMODE:=acFormAdd, WINDOWMODE:=acDialog, _
  5.         OpenArgs:=NewData
  6.     If ("PRODUCTF") Then
  7.         Response = acDataErrContinue
  8.         Docmd.Close acform, "productf"
  9.     Else
  10.         Response = acDataErrContinue
  11.     End If
  12. Else
  13.         Response = acDataErrContinue
  14.     End If
  15.  
  16. End Sub

i don't understand why it keeps on saying runtime error with this because i want to add items in my productcombo.Explain to me whats happening here and why the runtime?

lee123
Aug 19 '07 #1
11 1652
JConsulting
603 Recognized Expert Contributor
well this is a tough cookie this property, i just keep on getting a runtime error
with this can anyone tell me what is wrong with this code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PRODUCTCOMBO_NotInList(NewData As String, Response As Integer)
  2.  
  3.     If MSGBOX("THIS ISN'T IN THE LIST,DO YOU WANT TO ADD THIS?", vbYesNo + vbQuestion, "PLEASE RESPOND!") = vbYes Then
  4.         DoCmd.OpenForm "PRODUCTF", DATAMODE:=acFormAdd, WINDOWMODE:=acDialog, _
  5.         OpenArgs:=NewData
  6.     If ("PRODUCTF") Then
  7.         Response = acDataErrContinue
  8.         Docmd.Close acform, "productf"
  9.     Else
  10.         Response = acDataErrContinue
  11.     End If
  12. Else
  13.         Response = acDataErrContinue
  14.     End If
  15.  
  16. End Sub

i don't understand why it keeps on saying runtime error with this because i want to add items in my productcombo.Explain to me whats happening here and why the runtime?

lee123

Maybe a working example will help out.

Expand|Select|Wrap|Line Numbers
  1. if msgbox(newdata & " is not a current value. Add it?",vbyesno)=vbyes then
  2.      Response = acDataErrAdded
  3.      combo1=newdata  
  4.      DoCmd.OpenForm "formname", acNormal, , , , acDialog
  5.      docmd.gotorecord acform,"FormName",acnewrec
  6.      Forms!FormName!Field = newdata
  7. else
  8.      sendkeys "{Esc}"   'clears combo
  9.      response = acDataErrContinue
  10. end if
  11.  
  12.  
Aug 19 '07 #2
ADezii
8,834 Recognized Expert Expert
well this is a tough cookie this property, i just keep on getting a runtime error
with this can anyone tell me what is wrong with this code.

Expand|Select|Wrap|Line Numbers
  1. Private Sub PRODUCTCOMBO_NotInList(NewData As String, Response As Integer)
  2.  
  3.     If MSGBOX("THIS ISN'T IN THE LIST,DO YOU WANT TO ADD THIS?", vbYesNo + vbQuestion, "PLEASE RESPOND!") = vbYes Then
  4.         DoCmd.OpenForm "PRODUCTF", DATAMODE:=acFormAdd, WINDOWMODE:=acDialog, _
  5.         OpenArgs:=NewData
  6.     If ("PRODUCTF") Then
  7.         Response = acDataErrContinue
  8.         Docmd.Close acform, "productf"
  9.     Else
  10.         Response = acDataErrContinue
  11.     End If
  12. Else
  13.         Response = acDataErrContinue
  14.     End If
  15.  
  16. End Sub

i don't understand why it keeps on saying runtime error with this because i want to add items in my productcombo.Explain to me whats happening here and why the runtime?

lee123
This is not the typical approach for implementing the NotInList Property. Customarily, the NewData Value is added to the Record Source of the Combo Box by creating a Recordset based on the Table/Query and adding it programmatically. Any deviation from this approach may open the door for potential Errors.
Aug 19 '07 #3
lee123
556 Contributor
yea i got this out of a book i bought did know but i'll try yours thanks

lee123
Aug 19 '07 #4
missinglinq
3,532 Recognized Expert Specialist
We've been concentrating on the NotInList code for the calling form, but what's going on in the Form_Load event of the second form? Could the problem be in how the OpenArgs/NewData is being assigned at that end ?

Linq ;0)>
Aug 19 '07 #5
lee123
556 Contributor
well i tried your code. question, this code doesn't save the item in the list does it? when i executed the code and typed something in the combo box it worked fine but after i closed the form (productf) it gave me a error that said the "productf form isn't open" to give you an idea what im doing is this. i have a order form, product form. in the order form i have a subform (orderdetail form) that i put a combobox in it to add items to the subform (orderdetail) so when i have something that isn't in the list instead of going to the product form i would like to type it in the combobox named (productcombo) and have it open the form (new record) so i can add it to my list of products well i hope this explains it.

lee123
Aug 19 '07 #6
missinglinq
3,532 Recognized Expert Specialist
I'll ask you again; how is the OpenArgs/NewData (the new product you've entered into in the combobox) being assigned to the product field in the new record on the form "productf?" The code JConsulting posted as an example does it in Line # 6, but I see nothing in your code to do this! Is it handled in the Form_Load of the "productf" form?

You're getting the error about the form productf "not being open" because you've closed it manually, after entering whatever in the new record, then you have code to close it again!

Linq ;0)>
Aug 19 '07 #7
lee123
556 Contributor
now, now take it easy. like i said in the previous question i got this example out of a book. that being said as far as the openarg/newdata, what they have in this book is this:

Expand|Select|Wrap|Line Numbers
  1. if isloaded("formname") then
  2.     response=acdataerradded
  3.     docmd.close acform, "formname"
so i tried to make it work for me the code i posted is what they have in this book if i didn't post it all im sorry. but when i tried this code they have in the book it would except this line of code so i left it out or tried to go around it i took there example and changed there form name to mine and hoped it worked.

lee123
Aug 19 '07 #8
lee123
556 Contributor
i see i typed in the wrong code in mine i have:

Expand|Select|Wrap|Line Numbers
  1. if ("productf") then
  2.    response=acdataerrcontinue
  3.  docmd.close acform, "productf'
when it is suppose to be:

Expand|Select|Wrap|Line Numbers
  1. if ("productf") then
  2.    response=acdataerradded
  3.  docmd.close acform, "productf'
thats why you didn't see it in mine?

lee123
Aug 19 '07 #9
missinglinq
3,532 Recognized Expert Specialist
You also have if ("productf") then instead of if Isloaded("formname") then which is why, I suspect, you're getting the errror about the form not being open. The code from your book checks to see that the form is loaded before closing it, you code doesn't.

As I said before, the code you posted (that you got from your book) hasn't made any provision for assigning the NewData to the appropiate field of the form/record you're opening. I think you really need to refer back to this book and read thru it concerning this routine a little more carefully. I suspect that you've probably made additonal errors in going from the book to your ccode editor.

Linq ;0)>
Aug 19 '07 #10
lee123
556 Contributor
well, i altered the code and it works know thanks anyway.

lee123
Aug 20 '07 #11
missinglinq
3,532 Recognized Expert Specialist
Glad you got it figured out! Please post your final code so that others researching this or similar probelms in the future may benefit.

Linq ;0)>
Aug 20 '07 #12

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

Similar topics

4
by: Majed | last post by:
hi all i've created a strong named collection which inherits collection base,but when i try to add to it a nullreferenceexception blows. the code is as listed below. do i have to init the list...
1
by: Georg Scholz | last post by:
Hello, The class "Control" contains a documented Property "ControlType". So for example, in a form, you can write code like this: Dim c as control set c = me.Controls("textbox1") if...
6
by: Joe | last post by:
I have 2 multi-list boxes, 1 displays course categories based on a table called CATEGORIES. This table has 2 fields CATEGORY_ID, CATEGORY_NAME The other multi-list box displays courses based on...
3
by: jason | last post by:
Hello. I've got this simple collection populate code I downloaded from the net (sorry can't find source now) I'm trying to test, but I can't seem to get it to work. Any help would be greatly...
9
by: zacks | last post by:
I have written a serialized class that has several properties that are typed as a list of type class. When I deserialize an XML file, the list is populated just fine. But I am having trouble...
0
by: crazyone | last post by:
I've got a gaming framework i'm building and i want to save myself the trouble of reading and writting the complete game data to a custom file and load/save it to an XML file but i'm getting...
9
by: Paul | last post by:
Hi, I feel I'm going around circles on this one and would appreciate some other points of view. From a design / encapsulation point of view, what's the best practise for returning a private...
7
by: Donn Ingle | last post by:
Hi, I really hope someone can help me -- I'm stuck. I have written three versions of code over a week and still can't get past this problem, it's blocking my path to getting other code written. ...
6
by: Monty | last post by:
Hello, I have a singleton settings class (.Net 2.0 framework) that I serialize/deserialize to XML. On my settings class is a shared list of integers. If I have two numbers in my list and I...
11
by: Scott Stark | last post by:
Hello, The code below represents a singly-linked list that accepts any type of object. You can see I'm represting the Data variable a System.Object. How would I update this code to use...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.