|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with 3rd line of codeI'm having a hard time with a project and will explain what I did first, which had led to the error: First I've created a connection to the NWind.mdb Access file with the DataEnvironment1 from Visual Basic 6 in the "DataProject - DataEnvironment" window. Then I had added a Command1 for Connection1 in the "DataProject - DataEnvironment1" window. I then had changed Command1 in this window via the properties option so that the data source was a table within the NWind.mdb file. After I did this, I copied three fields of this table object from this window to frmDataEnv (Form1). From the Toolbox I had copied two command buttons and named them cmdPrevious and cmdNext. After double clicking one of the buttons, in design mode, to open the code view I had typed in: Private Sub cmdNext_Click() On Error GoTo MoveErr If Not DataEnvironment1.Recordsets.EOF Then DataEnvironment1.Recordsets.MoveNext End If Exit Sub MoveErr: MsgBox Err.Description End Sub Private Sub cmdPrevious_Click() 'Setup an error catching/reporting routine On Error GoTo MoveErr ' Check if the current record is the beginning 'of the file If Not DataEnvironment1.Recordsets.BOF Then 'Move the displayed record to the previous one DataEnvironment1.Recordsets.MovePrevious End If Exit Sub MoveErr: MsgBox Err.Description End Sub ------------------------------------ When I ran or executed the application and clicked on either command button instead of moving to a previous or next record within the table it gave the following error: ------------- Object Doesn't Support This Property or Method --------------------------------- Also, no code is highlighted for debugging. However, if I ad a Breakpoint AFTER the 3rd line of code I get the above error but not AT or BEFORE the 3rd line. I've also tried changing all occurances of Recordsets to Recordset in the code--since Recordsets is first used in this 3rd line of code--I then get the first occurance of Recordset highlighted, with the following error: ------------------------------- Compile Error: Method or data member not found ------------------------- What could be wrong and how can I fix this? Thanks in advanced for any feedback with this problem. 1. to get it right, make (temporarely) for each .object a different var so
you use early-binding and see the correct syntax 2. anyway, you are forgetting the index for the recordsets , but there is ONE current set only whcih could have records if there are more, u must handle them one by one 3. (TIP) dont use data environment Show quoteHide quote "netsurfer802" <netsurfer***@yahoo.com> schreef in bericht news:1127513685.489822.175620@z14g2000cwz.googlegroups.com... > Hello: > > I'm having a hard time with a project and will explain what I did > first, which had led to the error: > > First I've created a connection to the NWind.mdb Access file with the > DataEnvironment1 from Visual Basic 6 in the "DataProject - > DataEnvironment" window. > > Then I had added a Command1 for Connection1 in the "DataProject - > DataEnvironment1" window. I then had changed Command1 in this window > via the properties option so that the data source was a table within > the NWind.mdb file. After I did this, I copied three fields of this > table object from this window to frmDataEnv (Form1). From the > Toolbox I had copied two command buttons and named them cmdPrevious > and cmdNext. > > After double clicking one of the buttons, in design mode, to open the > code view I had typed in: > > Private Sub cmdNext_Click() > On Error GoTo MoveErr > If Not DataEnvironment1.Recordsets.EOF Then > DataEnvironment1.Recordsets.MoveNext > End If > > Exit Sub > MoveErr: > MsgBox Err.Description > End Sub > > Private Sub cmdPrevious_Click() > 'Setup an error catching/reporting routine > On Error GoTo MoveErr > ' Check if the current record is the beginning > 'of the file > If Not DataEnvironment1.Recordsets.BOF Then > 'Move the displayed record to the previous one > DataEnvironment1.Recordsets.MovePrevious > End If > > Exit Sub > MoveErr: > MsgBox Err.Description > End Sub > > ------------------------------------ > > When I ran or executed the application and clicked on either command > button instead of moving to a previous or next record within the > table it gave the following error: > ------------- > Object Doesn't Support This Property or Method > > --------------------------------- > Also, no code is highlighted for debugging. However, if I ad a > Breakpoint AFTER the 3rd line of code I get the above error but not AT > or BEFORE the 3rd line. > > I've also tried changing all occurances of Recordsets to Recordset in > the code--since Recordsets is first used in this 3rd line of code--I > then get the first occurance of Recordset highlighted, with the > following error: > > ------------------------------- > Compile Error: > > Method or data member not found > > ------------------------- > > > What could be wrong and how can I fix this? > > > > Thanks in advanced for any feedback with this problem. > |
|||||||||||||||||||||||