[RESOLVED]Data control Runtime Error 3426
Hello All
I am trying to setup a small database program for personal use, as i have done many times before. But for some reason i am having trouble getting this one to work.
I simply have a Data control filling in data bound text or combo boxes with the current selections data. But when i try to move to another selected record by using the
VB Code:
Dim Item As String
Item = dbcItemNumber.Text
Data1.Recordset.FindFirst "ItemNumber = '" & Item & "'
i get an error...
Runtime Error '3426'
This action was canceled by an associated object.
This is frustraing as this is the same code i've used for other programs and they worked and are still working. Also if i get rid of the variable Item and just have
VB Code:
Data1.Recordset.FindFirst "ItemNumber = 'X001'
It works.
Any ideas anyone?
Re: Data control Runtime Error 3426
what happens if you rename Item to sItem?
& what does the textbox have in it?
Re: Data control Runtime Error 3426
Exactly the same thing.
I've also had no variable and had
VB Code:
Data1.Recordset.FindFirst "ItemNumber = '" & dbcItemNumber.Text & "'
No matter what i get the same error msg.
Re: Data control Runtime Error 3426
Shouldn't it be:
VB Code:
"ItemNumber = '" & dbcItemNumber.Text & "'[B]"[/B]
Re: Data control Runtime Error 3426
The Input box is a data bound combo box (allthough i have also tried just straight text box) and it is populated with the records of the record set. Its meant to be used to select what record you want to move to.
Re: Data control Runtime Error 3426
Yes it should have an extra " that was just a typo for the forum. My program had the extra "
Sorry My bad.
Re: Data control Runtime Error 3426
i put a quote mark at the end of the string. although it shouldn't even compile with that missing - was it just a typo?
Re: Data control Runtime Error 3426
Try putting it in separate lines
sTemp = "ItemNumber = '" & Item & "' "
Data1.Recordset.FindFirst sTemp
Re: Data control Runtime Error 3426
or:
VB Code:
Data1.Recordset.FindFirst CStr("ItemNumber = '" & Item & "'")
Also double check the values being passed to it for rogue spaces and alike
Re: Data control Runtime Error 3426
2 Good theories but still no luck on both accounts.
As i said it's frustrating because i've done this so many times before with no troubles.
there has to be somthing obscure that i'm missing.
Re: Data control Runtime Error 3426
Does it work if you do this:
VB Code:
Dim sItem As String ' Item is a reserved word so I've changed it
sItem = "X001"
Data1.Recordset.FindFirst "ItemNumber = '" & sItem & "'"
If it does, then the problem is with the data being passed to the variable from the textbox
Re: Data control Runtime Error 3426
It sort of works.
During my error searching i have put the the code i first gave you into the click event of a button instead of the change event of the combobox.
So now with your new code if i start the program up and just press the button it changes the record to X001 but if i change the combobox first then i get the error msg.
Perhaps there is somthing with the data bound combo box but i've tried it just with a text box and got the same result (although the textbox was also data bound.)
Re: Data control Runtime Error 3426
I don't know enough about them to be of much more use i'm afraid: Bound Controls = Evil
Just use ADO instead :thumb:
Re: Data control Runtime Error 3426
Ok another development for us all to ponder over.
I put in an extra textbox not linked to the database and used this to type in the item numbers manually and use this value to update the record set and it worked but again if i changed the combobox then it all goes pear shaped again.
Perhaps you are right Dat abound controls = evil,
But when they work they make life so much easier.
Thank you for all you trying though.
cheers mate.
Re: Data control Runtime Error 3426
Ok I have found a solution.
If at first you don't suceed CHEAT!
I have removed the fieldbinding of the combobox. but left its list field binding so that i still get the comboboxes list updated by the recordset with all entered items. Then i just change the combobox's .text property on form load to equal the recordsets first item and it looks like it is exactly the same as before (except it works)
I hope all that rambling makes sense. Let me know if anyone needs me to breath then explain it more clearly.
thanks again all who helped out.
Cheers.
Re: [RESOLVED]Data control Runtime Error 3426
I'll say it again: Bound Controls = Evil :D
Glad you found a solution :thumb: