How to get all data updated to the new one
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: How to get all data updated to the new one

  1. #1
    Join Date
    May 2012
    Posts
    8

    Unhappy How to get all data updated to the new one

    Im trying to get those data in the database(access) update to the new date but the problem was it was not updated for all but only the first one. Please help me!...is it something problem with While Not Wend??
    Attached Files Attached Files

  2. #2
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: How to get all data updated to the new one

    Well, one needs a HD widescreen display to read your code.
    Please comment more on it. Which is the Loop you are talking about?

  3. #3
    Join Date
    May 2012
    Posts
    8

    Re: How to get all data updated to the new one

    While Not rstData4.EOF

    If rstData4("SpecID") = SpecId Then
    ReviewDate3 = UCase$(Trim$(NullReturn(rstData4("SpecLastUpdate"), "")))
    ReviewDate3 = rstData4("SpecLastUpdate")
    ReviewDate4 = DateAdd("m", 60, ReviewDate3)
    EffectiveDate2 = ReviewDate4
    GoTo FoundSpec
    Else
    rstData4.MoveNext
    End If

    Wend



    okey, I have rstData3 and rstData4 which are the databases in access. Those databases have same specid and title and i compared in order to get the date(speclastupdate) that only have in rstData4.

    SpecId = rstDate3
    ReviewDate3 = the name for speclastupdate in rstData4
    ReviewData4 = new date after dateadd
    EffectiveDate2 = date displayed in output attached (EFFECTIVE_DATE)

    Hope these information will good enough for u to help me to figure out what was the problem? please..
    Attached Files Attached Files

  4. #4
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008
    Location
    WV
    Posts
    4,845

    Re: How to get all data updated to the new one

    I'm not even sure what you are asking. There is no code shown that does an update so nothing would be updated by what is given.

    Your while loop will find the first match then jump out of the loop via the goto. If you want to retrieve more than one then you need to do something different.

    As a general rule you should avoid usig Goto, I see you have used it several times which makes for very sloppy code and there really is no need to use them. A properly structured If statement will eliminate the need for those in most cases.

    As for getting the updated data rather than looping through all the records you should be selecting the records you want from the database so that your resulting recordset contains only those records you want.

    i.e. "Select * from Table where Specid=" & specid
    Always use [code][/code] tags when posting code.

  5. #5
    Join Date
    Jul 2006
    Location
    Germany
    Posts
    3,722

    Re: How to get all data updated to the new one

    Too true about the Gotos, DataMiser.

    masyus, in your code there are at least 2 similar While Not rstData4.EOF loops. They both have a Goto FoundSpec command, but there is only one label named FoundSpec, and for the second loop this lies within a different If statement. I wonder why you are not getting a compiler error with that one. You may not jump into an If clause from another If clauses code.

    You should try to structure your task in a more logical way and really try to avoid Gotos.

  6. #6
    Join Date
    May 2012
    Posts
    8

    Re: How to get all data updated to the new one

    okey

    thanks for your advised. I will try again...well actually im new in this programming's world hehe..

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center