Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrrgh! Data Environment doin my nut!

Status
Not open for further replies.

DannyTmoov2

IS-IT--Management
Jan 7, 2003
49
GB
Hi all, I have an AccessXP database, am trying to use dataenvironment to call up records into text boxes in a VB6 project.

I have set up a simple form with 2 text boxes pointing at 2 fields in a table (using datasource as the dataenvironment, data member as the table and datafield as the field).

On the form I use the following code: -

Private Sub Form_Load()
dePMIS.rsTABLENAME.Open
dePMIS.rsTABLENAME.MoveFirst
End Sub

However I can not see the field values in the text boxes, however I believe the table is being accessed because if I add some next and previous buttons: -

Private Sub Command1_Click()
dePMIS.rsTABLENAME.MoveNext
End Sub

Private Sub Command2_Click()
dePMIS.rsTABLENAME.MovePrevious
End Sub

I can click through the same number of times as there are records before getting the EOF error.

Pleeeeeeeeeeeeeaaaaaaaaaaaaassssseeee help, its driving me mad!

Could it be a driver issue? I am using XP pro- SP1, with VB6 using JET 4.0

Thanks in advance if anyone can shed any light???????????????????!!!!!
 
I dont know if you have done this
but you must set the text boxes equal to something...

Text1.Text = Recordset!FieldName
Recordset = name of ADO Recordset
FieldName = DB Table Field name for the value you wish to display
(shortened version for recordset.Fields("Fieldname").Value)

-vza
 
Doesn't setting the datasource properties achieve this?
 
Nope,

Try this...
[blue]
Option Explicit

Private Sub cmdNextRec_Click()
rs.Movenext [green]'Moves to the next record[/green]
Call AssignData [green]'Calls procedure to assign data to textbox[/green]
End Sub

Private Sub cmdPrevRec_Click()
rs.MovePrevious [green]'Moves to the previous record[/green]
Call AssignData [green]'Calls procedure to assign data to textbox[/green]
End Sub

Private Sub Form_Load()
[green]'Set New Record Sets and Connection[/green]
Set DBcn = New ADODB.Connection
Set rs = New ADODB.Recordset

DatabaseLocation = ("C:\Database.mdb")
DBcn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source= " & DatabaseLocation & ";"

[green]'Defines what table and field to retrive the information from[/green]
rs.Open "SELECT * FROM Table1", DBcn, adOpenStatic, adLockReadOnly, adCmdText

Call AssignData [green]'Calls procedure to assign data to textbox[/green]
End Sub

Private Sub AssignData()
Text1.Text = rs!Field1
Text2.Text = rs!Field2
Text3.Text = rs!Field3
End Sub
[/blue]

I hope this is what you are looking for...
Cheers
Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top