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. - Private Sub PRODUCTCOMBO_NotInList(NewData As String, Response As Integer)
-
-
If MSGBOX("THIS ISN'T IN THE LIST,DO YOU WANT TO ADD THIS?", vbYesNo + vbQuestion, "PLEASE RESPOND!") = vbYes Then
-
DoCmd.OpenForm "PRODUCTF", DATAMODE:=acFormAdd, WINDOWMODE:=acDialog, _
-
OpenArgs:=NewData
-
If ("PRODUCTF") Then
-
Response = acDataErrContinue
-
Docmd.Close acform, "productf"
-
Else
-
Response = acDataErrContinue
-
End If
-
Else
-
Response = acDataErrContinue
-
End If
-
-
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
11 1652
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. - Private Sub PRODUCTCOMBO_NotInList(NewData As String, Response As Integer)
-
-
If MSGBOX("THIS ISN'T IN THE LIST,DO YOU WANT TO ADD THIS?", vbYesNo + vbQuestion, "PLEASE RESPOND!") = vbYes Then
-
DoCmd.OpenForm "PRODUCTF", DATAMODE:=acFormAdd, WINDOWMODE:=acDialog, _
-
OpenArgs:=NewData
-
If ("PRODUCTF") Then
-
Response = acDataErrContinue
-
Docmd.Close acform, "productf"
-
Else
-
Response = acDataErrContinue
-
End If
-
Else
-
Response = acDataErrContinue
-
End If
-
-
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. -
if msgbox(newdata & " is not a current value. Add it?",vbyesno)=vbyes then
-
Response = acDataErrAdded
-
combo1=newdata
-
DoCmd.OpenForm "formname", acNormal, , , , acDialog
-
docmd.gotorecord acform,"FormName",acnewrec
-
Forms!FormName!Field = newdata
-
else
-
sendkeys "{Esc}" 'clears combo
-
response = acDataErrContinue
-
end if
-
-
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. - Private Sub PRODUCTCOMBO_NotInList(NewData As String, Response As Integer)
-
-
If MSGBOX("THIS ISN'T IN THE LIST,DO YOU WANT TO ADD THIS?", vbYesNo + vbQuestion, "PLEASE RESPOND!") = vbYes Then
-
DoCmd.OpenForm "PRODUCTF", DATAMODE:=acFormAdd, WINDOWMODE:=acDialog, _
-
OpenArgs:=NewData
-
If ("PRODUCTF") Then
-
Response = acDataErrContinue
-
Docmd.Close acform, "productf"
-
Else
-
Response = acDataErrContinue
-
End If
-
Else
-
Response = acDataErrContinue
-
End If
-
-
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.
yea i got this out of a book i bought did know but i'll try yours thanks
lee123
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)>
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
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)>
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: - if isloaded("formname") then
-
response=acdataerradded
-
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
i see i typed in the wrong code in mine i have: - if ("productf") then
-
response=acdataerrcontinue
-
docmd.close acform, "productf'
when it is suppose to be: - if ("productf") then
-
response=acdataerradded
-
docmd.close acform, "productf'
thats why you didn't see it in mine?
lee123
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)>
well, i altered the code and it works know thanks anyway.
lee123
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)> Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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: 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...
|
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,...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
| |