I don't recall ever having trouble using a similar procedure in the past but for some reason this one is giving me tons of trouble. Everytime it gets executed, it fires "Object doesn't support this property or method" error and I just can't understand why.
Here is the snippet

SelectedEntry = Val (LogGrid.TextMatrix(LogGrid.Row,1))

datLoggedEntry.DatabaseName = App.Path & "\ndbdata.mdb"

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID=" & SelectedEntry
datLoggedEntry.Refresh

Even if I was to replace SelectedEntry variable with a number, I still get this error...
Any idea why?????

Recommended Answers

All 11 Replies

Please give us more details like where is the line your getting that error..

In the past when I've used a Datagrid, I've generated a recordset with data from the database first and used that as the RecordSource for the grid control.

(this is of course based on the assumption that you are using a Datagrid :))

The error occurs right at the REFRESH command.

Yes, I'm using a grid at the moment but I can't see how this is causing the problem because I can replace the line

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID=" & SelectedEntry

with

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID= 425

and still get the same error.
Now, here is the kicker... if there is a record that matches this number (425), the error is generated but if none of the records match this number, no error is being generated... weird, huh?

I don't know for definite, but could it be because you are getting the SelectedEntry value using Val() as if I remember right, that would return a Double value which I wouldn't imagine to be typically used for an ID in a database. What happens if you use CStr() for a string or CLng() for a long instead?

I was thinking that as well. Since the Beacon_ID field in the database is defined as a Long Integer. But if it was a value definition conflict, how come the other line

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID = 425"

returns the same error?

How is NDBLog defined?

Ummm... NDBLog is a table (amongst many others) within a database. I had no idea it could be defined.

I was thinking that as well. Since the Beacon_ID field in the database is defined as a Long Integer. But if it was a value definition conflict, how come the other line

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID = 425"

returns the same error?

Good point. I forgot you had already mentioned that hard-coding the value into the SQL statement made no difference.

On checking in VB6 though now, I've seen that the standard Datagrid doesn't have DatabaseName or RecordSource properties (instead it has the DataSource property). I therefore presume you are using a different grid control?

Edit: Come to think of it, neither the MSFlexgrid or MSHFlexGrid have a RecordSource property either. Are you using a custom ActiveX control?

Acutally no custom controls... I'm using MSFlexGrid, which DOES have a Datasource property. I have always used it in the past and never had any trouble... until now.
The more I think about it, the more it looks like there might have been something in code that happens right before this routine. I'll have to retrace my steps and eliminate some stuff (especially stuff that deals with accessing the database) and see if this routine will execute properly.
I will also try modifying the query to search other fields in that table. Maybe there is an issue with the Beacon_ID field? Hmmmm....

If not solved yet, this is what I could pick up.

Your value returned from the grid looks fine, although you do not have to specify the return as a value "Val()".

Your select statement is incorrect though. This might be where the error gets triggered.

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID =" & SelectedEntry

'This should rather be ---

datLoggedEntry.RecordSource = "Select * FROM NDBLog WHERE Beacon_ID =" & "'" & SelectedEntry & "'"

datLoggedEntry.MoveFirst

This is all presuming that there is an ID with that number (425) in the table, otherwise more errors will occur.

Normally "Object ...." error is when you are referencing something to an object improperly. I have not played around with the grid's code to see if you have maybe referenced anything wrong there, it looks fine.

Problem solved!!!

I stopped concentrating one the query statement and went a little further to see if there was anything else tied to the data control that would make it go sour.
Lo and behold I found it. What had happened was that there were a couple of text boxes on the display whose Datasource property was set to the data control in question - no problem there. But their recordsource properties were set to a field that does not exist in the table!
This program was working before but I've decided to clean up the database table a bit and change the headings in that table, but I totally forgot to modify the texboxes to reflect that change!
Oh man, that was quite a head scratcher. I know you guys tried your best to help out but I sensed confusion on the board and that's what tipped me off to maybe look elsewhere in the program to try to find the problem.

Thank you to all who have replied. I appreciate your efforts very much.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.