VB6 Data control and Excel

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

VB6 Data control and Excel

Post by agibsonsw »

Hello.
I'm using Visual Basic 6 and want to use the Data control to connect to an Excel workbook.
I've created an ODBC, DSN 'Staff' for my workbook and my workbook only has one worksheet - with the
data beginning from A1.
I've added the Data control, set the DefaultType to 'Use ODBC' and typed Staff as the Database Name.
Do I need to set the Recordsource to something - it doesn't allow me to anyway?
Do I need to change any other properties of the Data control?
I've set the DataSource of a textbox to the name of the Data control, but what other properties do I need
to set? I've set the DataField to 'StaffID' (the 1st column of my data) but nothing appears in the control.

Thanks for any assistance offered. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: VB6 Data control and Excel

Post by agibsonsw »

.. while awaiting a response, I'm trying the ADO Data Control (6.0) instead, which I understand is preferable.
I set up a DSN for the Excel workbook and set the RecordSource for the control to a named range. This works fine,
but the data is not update-able. I receive an error about the string or buffer length being invalid.

Is it possible to update Excel data using the ADO Data Control? Thanks in advance. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
rory
5StarLounger
Posts: 817
Joined: 24 Jan 2010, 15:56

Re: VB6 Data control and Excel

Post by rory »

Did you specify that your DSN should not be read-only (the default is read-only)?
Regards,
Rory

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: VB6 Data control and Excel

Post by agibsonsw »

Hello.
Yes, I spotted that option. Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.