PDA

Click to See Complete Forum and Search --> : Newbie Data Control Problem


MPHymel
Aug 22nd, 2000, 10:23 AM
I am somewhat new at VB. I am using (or abusing) VB 6 pro.

I am trying to use the data control, and want to set the databasename property at runtime.

I am using the datacontrol on a simple form that is activated by one of two buttons. One maps the data control to spreadsheet "A" the other to spreadsheet "B". I am using a third spread sheet as a default null file to point to at startup.

I set a public variable with the appropriate file name according to which button is pressed. The form with the datacontrol is then activated using the .show method.

The Load event on the form with the data control sets the database name equal to the variable, then sets the .recordsource to sheet1 (all spreadsheets are using sheet1) then issue a .refresh method.

When I close this form, I set the databasename back to the null spreadsheet, and do a refresh.

The first time I hit either button, it works ok.

The next time I hit either button, it does not work, the control stays connected to the null spreadsheet.

Am I not seeing something here? Any suggestions?

Thanks in advance! :?)

bar
Aug 22nd, 2000, 11:36 AM
Only workaround that i've found for this is to use a Database and Recordset object.

Every time your button is clicked, refresh these to objects and add a third line as follows:

Set datacontrol.Recordset = recordset object

This works quite well, I've been using it for years.