Using a Data Control and MS Access 
Author Message
 Using a Data Control and MS Access

I'm new to VB 5 so nothing is going quite right.  I have a form that uses a
TabStrip (I don't have access to a "Tabbed control in the version I own.)  I
want each page to display data from an access DB.  I have placed my Data
Control object on the main part of the form so that it does not disappear
when the form gets tabbed.

The problem that I am having is that I need to be able to change the data
control's RecordSource dynamically.  I wrote code that I thought would
dynamically set the recordsource to various queries in the database  but VB
5 is unimpressed.

Private Sub TabStrip1_Click()
    If TabStrip1.SelectedItem.Index - 1 <> mintCurFrame Then
        fraTab1(mintCurFrame).Visible = False
        Select Case TabStrip1.SelectedItem.Index - 1
            Case 0
                Data1.RecordSource = "qryCharacterInfo"
            Case 1
                Data1.RecordSource = "qryCharacterSkill"
            Case Else
                MsgBox ("TabStrip1_Click()  Case value is out of bounds.")
        End Select
        fraTab1(TabStrip1.SelectedItem.Index - 1).Visible = True
        mintCurFrame = TabStrip1.SelectedItem.Index - 1
    End If
End Sub

Any suggestions?

Thanks



Fri, 25 May 2001 03:00:00 GMT  
 Using a Data Control and MS Access
I believe that after you change the record source you need to refresh the
data (e.g. data1.refresh)
and the databound controls. (the tab strip, text boxes and so on....)

Yossi

Quote:
>The problem that I am having is that I need to be able to change the data
>control's RecordSource dynamically.  I wrote code that I thought would
>dynamically set the recordsource to various queries in the database  but VB
>5 is unimpressed.

>Private Sub TabStrip1_Click()
>    If TabStrip1.SelectedItem.Index - 1 <> mintCurFrame Then
>        fraTab1(mintCurFrame).Visible = False
>        Select Case TabStrip1.SelectedItem.Index - 1
>            Case 0
>                Data1.RecordSource = "qryCharacterInfo"
>            Case 1
>                Data1.RecordSource = "qryCharacterSkill"
>            Case Else
>                MsgBox ("TabStrip1_Click()  Case value is out of bounds.")
>        End Select
>        fraTab1(TabStrip1.SelectedItem.Index - 1).Visible = True
>        mintCurFrame = TabStrip1.SelectedItem.Index - 1
>    End If
>End Sub



Sat, 26 May 2001 03:00:00 GMT  
 Using a Data Control and MS Access
Add the following line in after change the recordsource property:
data1.refresh


Sat, 26 May 2001 03:00:00 GMT  
 Using a Data Control and MS Access
Try a "Data1.Refresh" after you change the recordsource.

Quote:
>The problem that I am having is that I need to be able to change the data
>control's RecordSource dynamically.  I wrote code that I thought would
>dynamically set the recordsource to various queries in the database  but VB
>5 is unimpressed.
>                Data1.RecordSource = "qryCharacterInfo"

Data1.Refresh


Thu, 07 Jun 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using MS Data Control DAO to access a password protected database

2. Help..Using VB6 Data Control to access MS SQL Server7 Database

3. Using VB5 to import data to access without using the Data control

4. Regarding Accessing External database using MS-Access and MS-Visual Basic

5. Write data from excel to MS-Access using VBA

6. using vb.net to extract data from ms access

7. using the data in a MS Access file

8. Trying to get data from MS Access table (not using ASP)

9. Using an MS Access DB as the data storage

10. Using an MS Access DB as the data storage

11. Importing data to MS Access using VB

12. Using a Data Control in VB5 accessing a user-level secure Access 97 DB

 

 
Powered by phpBB® Forum Software