Problem with RecordSource

Problem with RecordSource

Post by Marc Harri » Sat, 04 Apr 1998 04:00:00



I am new to Visual Basic and I am writing a small Database program to
become more familiar with it.  But I have run into a problem.  My
problem is that I have a File Open menu option which lets you choose the
Database you want to open, but I can't figure out how to set the
RecordSource at run time.  I have figured out how to set the Database
name:
            Data1.DatabaseName = CommonDialog1.filename
But I can't figure out how to show the underlying table for that
Database, so that I can set it equal to the RecordSource.  I can set it
in the Properties, but I want to be able to do it at run time.  I'm not
even sure if I am doing this right, but any help would be greatly
appreciated.
        Thanks,
                Marc

 
 
 

Problem with RecordSource

Post by JohnMOU » Sun, 05 Apr 1998 04:00:00


Quote:>I am new to Visual Basic and I am writing a small Database program to become

more familiar with it.  But I have run into a problem.  My problem is that I
have a File Open menu option which lets you choose the Database you want to
open, but I can't figure out how to set the RecordSource at run time.  I have
figured out how to set the Database name:
            Data1.DatabaseName = CommonDialog1.filename
But I can't figure out how to show the underlying table for that
Database, so that I can set it equal to the RecordSource.  I can set it in the
Properties, but I want to be able to do it at run time.  I'm not
even sure if I am doing this right, but any help would be greatly
appreciated. <

I use bound Data Controls and change the RecordSource Property by:
Data1.RecordSource = sSQL
                        Data1.Refresh
where sSQL is a SQL Query in double quotes.  Maybe all you
need to do is to put the table name in double quotes instead.

 
 
 

Problem with RecordSource

Post by chdp » Sun, 05 Apr 1998 04:00:00



Quote:>I am new to Visual Basic and I am writing a small Database program to
>become more familiar with it.  But I have run into a problem.  My
>problem is that I have a File Open menu option which lets you choose the
>Database you want to open, but I can't figure out how to set the
>RecordSource at run time.  I have figured out how to set the Database
>name:
>            Data1.DatabaseName = CommonDialog1.filename
>But I can't figure out how to show the underlying table for that
>Database, so that I can set it equal to the RecordSource.  I can set it
>in the Properties, but I want to be able to do it at run time.  I'm not
>even sure if I am doing this right, but any help would be greatly
>appreciated.
>        Thanks,
>                Marc

Private Sub RecordSourceSet()
  With Data1
    .DatabaseName = "MyDb.mdb"
    .RecordSource = "MyTable"
    .Refresh
    With .Recordset
      ' ... work with MyTable
    End With
  End With
End Sub


 
 
 

1. Problem Setting RecordSource - Please Help

I'm running VB 4.0 Enterprise Edition 32 bit. I'm having a problem setting
a data control's RecordSource property to an SQL string. If I use this same
string to build and run a query in Access 7.0 it works fine but when I
say:

pdContract.RecordSource = SQLString
pdContract.Refresh

where pdContract points to data control on another form (I verified that it
really does) and SQLString is a text variable holding a valid SQL
statement.

When it hits the refresh I get a "couldn't find object '< the text of my
SQL String>'" message. Any ideas?

2. i dont use < ' > character in fields !!!

3. Problem with Recordsource Property / Error 3011 or Error 3024 HELP

4. crsytal report8

5. Problem: Recordsource Not Updatable

6. Howto get a list of all odbc sources which are in the DSN

7. Grid's recordsource problem

8. Ingres 8.9 on SUN

9. ADO Recordsource SQL Problem

10. Data Control recordsource problem

11. RecordSource Problem

12. Ado recordsource string problem

13. RecordSource Problems