Result of SQL Query in textbox - 1st matching record is missing ? URGENT!

VBKid04
04-14-2004, 05:44 PM
This is absolutely baffling me...

My code is now like this:

Dim sqlQuery As New ADODB.Recordset
Set sqlQuery = db.Execute("SELECT TaskDetails From TASK WHERE TASK.CustomerID='" & txtCustomerID & "'")

txtDetails.Text = sqlQuery!TaskDetails


which would appear to be correct, but there seems to be a flaw somewhere.


When I use the above code, I get the error:
Either BOF or EOF is true, or the current record has been deleted.
when I open my form.

I have tried the code both in the txtTaskID_Change and Form_Load.


I have checked the database and what its saying is nonsense, as the first record in the table clearly has a match and should display when the form opens...


So as a test:
On my form I have put a listbox called lstDetails (I dont need this listbox, but I'm just testing).
Instead of passing the result to the textbox, I have then passed it to the listbox (and commented out the line to do with the textbox).

Strangely enough, the form opens, with no error.


But what else I notice, is that when the form opens at the 1st record, the listbox is empty (there should be a value in it due to the query because it has a match in the other table).

If I browse forward 1 record (to the 2nd), a matching value appears in the listbox.

Then if I browse back 1 record (now at the 1st record), the matching value appears in the listbox! (The value that should have appeared on opening the form).

So clearly, when the form is opening, the value cannot be instantiated, because it is seeing the TaskDetails field as empty for the 1st record - but why, when it clearly is not?

I have tried using the code both on the txtTaskID_Change properties and the Form_Load properties, but both have exactly the same results.


Back to the textbox method... I have setup an error handler to ignore the error, as the problem is only whenever the form opens for the first time.
But this is no good as the whole recordset then disappears completely!


Can someone please help me here?
I am on the point of insanity!

MKoslof
04-14-2004, 05:57 PM
Please don't cross post...this is being handled in another thread. We can't help you if consistenly start new threads.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum