Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bounding TextControl to fields.
Message
 
To
26/03/2001 15:07:18
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Miscellaneous
Thread ID:
00488669
Message ID:
00488781
Views:
11
>Hello,
>
>I'm testing a form that displays first_name and last_name from a SQL70 table called OptOut ( database is also called OptOut ).
>Below is the code to establish the connection and recordset(Hope is Ok).
>How should I set the following textbox control properties ? :
>I've been trying to display the first_name and last_name but I've been unsucssefull.
>Also can I set these properties at deign time.

Use this:
Option Explicit


Dim cnMyConnection As Connection
Dim recMyRecordSet As Recordset
Dim comMyCommand As Command

Private Sub Form_Load()
Set cnMyConnection = New Connection
Set recMyRecordSet = New Recordset
Set comMyCommand = New Command

' Establish connection
With cnMyConnection
.ConnectionString = "Provider=SQLOLEDB;Integrated Security=SSPI;Initial Catalog=pubs;Data Source=(local)"

.Open
End With

' Create a command object
With comMyCommand
.ActiveConnection = cnMyConnection
.CommandText = "SELECT * FROM Authors"

' Build the record set
Set recMyRecordSet = comMyCommand.Execute
End With

With Text1
    Set .DataSource = recMyRecordSet
    .DataField = "au_lname"
End With

With Text2
    Set .DataSource = recMyRecordSet
    .DataField = "au_fname"
End With
End Sub
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform