Results 1 to 17 of 17

Thread: Moving to Next Record, and updating Data Bound Controls

  1. #1

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Question Moving to Next Record, and updating Data Bound Controls

    Hey guys,

    have a problem. i am forced to use DataEnvionment so dont suggest otherwise. i know it sux.

    anyway i have a few controls which is kind of 'data bound' to a recordset in a data environment.

    now i want to do a simple record navigation.

    like .movenext, etc.

    but when i movenext from the Recordset, the DataBound controls doesnt update with the new data. infact, nothing visibly happens.

    any suggestions ?

    this is the code im using

    Private Sub cmdNext_Click()
    If DataEnv.rsLect.State <> adStateClosed Then DataEnv.rsLect.Close
    DataEnv.rsLect.Open
    DataEnv.rsLect.MoveNext
    DataEnv.rsLect.Close
    End sub


    thanks
    Deane.
    me.life = VB

  2. #2
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    I always displays the first record...right?

  3. #3

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Moving to Next Record, and updating Data Bound Controls

    yeah
    Last edited by deane034; May 14th, 2006 at 03:33 PM.
    me.life = VB

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    By default the Open method selects the first record in the recordset... since your repeatedly opening the rs...

    Also since your closing the rs with each click then the data bound controls will not be bound to an open recordset.

    If the recordset will be navigated throughout the duration of the form life, then issue the Open method in the Form load event... and the close method in the form unload event.

  5. #5

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Re: Moving to Next Record, and updating Data Bound Controls

    hey Leinad,

    thanks. i tried what you said but the result is the same. ??
    me.life = VB

  6. #6

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Re: Moving to Next Record, and updating Data Bound Controls

    I also tried giving a simple command like
    MsgBox DataEnv.rsLect.Fields("FName")

    in this case it outputs the correct record name. just that the DataBound Controls my text boxes, etc dont update.
    i tried textbox.refresh that too doesnt seem to work
    me.life = VB

  7. #7
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    Have you set the DataSource, DataField, etc properties of the textboxes?

  8. #8

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Re: Moving to Next Record, and updating Data Bound Controls

    hey Lein, Thanks again. yes i have.

    figured it out though, have to RE SET the Data Source each time you move a record.
    for e.g
    Set txtFName.DataSource = DataEnv

    insanity!

    cheers
    Deane.
    me.life = VB

  9. #9
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    There should have been no need to reset anything with code actually since its all pre-determined and data bound during design time.

    Resorting to progmatic means during run-time defeats the pupose of using the data environment.

  10. #10

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Re: Moving to Next Record, and updating Data Bound Controls

    i agree, but does anyone else have a better way of doing it? or anyway of doing it for that matter ?
    me.life = VB

  11. #11
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    SQL queries and ADO.

  12. #12

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Re: Moving to Next Record, and updating Data Bound Controls

    like i said im stuck with DateEnv
    me.life = VB

  13. #13
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    Is this source code your predecessor's and was passed on to you?

    You can still use SQL + ADO rather than updating/adding to the data environment.
    Last edited by leinad31; May 15th, 2006 at 01:28 PM.

  14. #14

    Thread Starter
    Hyperactive Member deane034's Avatar
    Join Date
    May 2001
    Location
    Sri Lanka
    Posts
    485

    Re: Moving to Next Record, and updating Data Bound Controls

    no no it's an assingment man specifically DataEnv thanks for the help tho.
    me.life = VB

  15. #15
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    IMO, teachers really should stop over-emphasizing the use of these data-bound controls...

    If you have the time, it would be better for you to learn ADO... the data environment is just a point-click GUI wrapper for ADO... so if you already know ADO, then learning the use of the data environment is easier... and the underlying concepts are more important, especially when your already a professional programmer.

  16. #16
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: Moving to Next Record, and updating Data Bound Controls

    Quote Originally Posted by leinad31
    IMO, teachers really should stop over-emphasizing the use of these data-bound controls...
    When you have 2 weeks to teach database programming, that's about the only way you can do it.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  17. #17
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: Moving to Next Record, and updating Data Bound Controls

    I was aware of the time constraint, its use for instruction is unavoidable but they should let the students know thats its just a GUI wrapper... that's what I meant by over emphasizing.

    And since you mentioned the limited time period hehehehe. Most programmers expect themselves to work for companies in the future... all companies have accounting related activities (report generation included)... database use is usually related to these accounting related activities... hence a competitive (in the typical/non-specialized business sector) graduate should be given more exposure to database programming (and accounting basics), not just two weeks crash course.

    That's just my opinion on the matter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width