Find duplicate record and pass its values to the boxes for update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • strive4peace
    Recognized Expert New Member
    • Jun 2014
    • 39

    #16
    thanks, Z -- thought since he attached the image, he could attach a file too ... still, and always, learning. I would like to see his project to figure it out myself too :)

    Comment

    • hefaz
      New Member
      • Nov 2015
      • 24

      #17
      ok guys I will just zip the database along with the form and buttons, Just give it a look.

      Comment

      • hefaz
        New Member
        • Nov 2015
        • 24

        #18
        when I want to enter records to the boxes, then I click check button to check if the record already exists, which's indexed value(no duplicates)is the name field. if it exists than give me that message in the code (second pic)and give its values to the boxes than I click update button to update that record. and if not than create a new record,
        well this works, but when I enter a records that is already In the database, than give me an error message (third pic) now correct that for me. I have included the zipped folder.
        That would be your pleasure if you guys give me your email, so that I would be able to send the complete project.
        (capture.jpg)
        [IMGnothumb]https://bytes.com/attachment.php? attachmentid=85 31[/IMGnothumb]

        CheckCode.JPG
        [IMGnothumb]https://bytes.com/attachment.php? attachmentid=85 32[/IMGnothumb]

        Error.jpg
        [IMGnothumb]https://bytes.com/attachment.php? attachmentid=85 33[/IMGnothumb]
        Attached Files
        Last edited by zmbd; Nov 15 '15, 11:12 PM. Reason: [op{privacy}][z{in-lined images}]

        Comment

        • zmbd
          Recognized Expert Moderator Expert
          • Mar 2012
          • 5501

          #19
          + Usually we ask our membership not to use private emails for topics online unless the information is sensitive in nature and we involve the site administration.

          + The code posted in the image.
          This is nothing like what we've suggested/advised and as it stands will not work as there is no check between the database and the form. You must use some method, even if you have to emulate the DLookup() (see tutorial here on how to do that in VB: How to Implement the DLookup Function in Visual Basic ), to look the value up first.

          Thus, User enters data, Clicks on [Check] Button, Code runs the look up via either the emulated Domain function or as we have suggested via record-set, if the code finds the value then retrieve and populate the controls on the form and enables the [Update] button, if the code doesn't find the value then create a new record and save the form data... maybe provide a bit of user feed back to that effect.
          Last edited by zmbd; Nov 15 '15, 11:24 PM.

          Comment

          • hefaz
            New Member
            • Nov 2015
            • 24

            #20
            exactly zmbd.
            your third paragraph is my problem, now is there any way to do what I want? or is that a nonsense idea of mine? please tell me if the code s4p wrote will work for this problem. or write your own and final idea, because I know I have created a headache for you guys, nothing else.

            sorry I am new here and still don't understand the basics of the site. p i.e privacy etc.

            wow, thanks for the nice suggestion, about dlookup, I will try it, I think that is my problem.

            sorry I failed to do that, if someone create just a sample for me that would be better, otherwise I can't.
            Last edited by zmbd; Nov 16 '15, 11:46 AM. Reason: [z{merged the 4 posts}]

            Comment

            • zmbd
              Recognized Expert Moderator Expert
              • Mar 2012
              • 5501

              #21
              + Usually we do not write the entire code, instead, we try to help guide our membership to look at all of the options available and decide the best route for themselves.

              The reasoning is two fold:
              ++ Primarily, because there are usually multiple methods to arrive at a solution and no one approach is a panacea
              ++ Because, when one finds the solution oneself the methods learned become more valuable in that one usually learns how to apply the tools in more situations.
              Give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime.

              - Maimonides

              + The code S4P has provided is a framework that you will need to modify to fit your situation.

              Comment

              • hefaz
                New Member
                • Nov 2015
                • 24

                #22
                yeah, that gave me really a good sense and felling, thank you from the advice. that is right, I will try hard to reach to my problem's solution, and will post the answer back here. thank you both for the contribution.
                THOSE WHO STRUGGLE MAY FAIL, BUT THOSE WHO DON'T STRUGGLE HAVE ALREADY FAILED.

                Comment

                • zmbd
                  Recognized Expert Moderator Expert
                  • Mar 2012
                  • 5501

                  #23
                  hefaz,
                  Your thread has definitely highlighted a weakness in my understanding of VB6 as it relates to Access. To that end I started looking around for more information about how to handle Access in VB.

                  I've found the following tutorial, it mentions using ADO as the primary means of manipulating Access database objects; however, with the advent of the "ACEDAO" (currently Access 2007 and newer) - I think it advisable to learn how to handle the "DAO" methods described within the tutorial. Using the native engine language to handle data seems to be the best route. I use ADO methods when push/pull data to a SQL-Server or MYSQL because the ADO translates better to those servers.

                  In any case here's the link - keep in mind that this tutorial references older libraries (3.51) however the newest version is ACE 12.0 ((Database.Versio n Property (DAO) )) So some things such as user level security are no longer available: http://www.vb6.us/guides/vb6-database-guide

                  In any-case, this is the one I am staring with, I found three others that appear to be newer and I'll be looking thru too - but they don't appear to be for "the faint of heart." Thus, this one is just as a primer for me as I do not develop in VB, even though it references older material it may provide some useful insights for your project.

                  Best of Luck with your project.
                  Last edited by zmbd; Nov 17 '15, 02:01 PM.

                  Comment

                  • hefaz
                    New Member
                    • Nov 2015
                    • 24

                    #24
                    Thank you man. Rated you as best moderator with 5 stars.

                    Comment

                    • hefaz
                      New Member
                      • Nov 2015
                      • 24

                      #25
                      still working on the problem guys...

                      Comment

                      • zmbd
                        Recognized Expert Moderator Expert
                        • Mar 2012
                        • 5501

                        #26
                        hefaz,
                        Have you a revised code?
                        What further steps have you taken?

                        Comment

                        • hefaz
                          New Member
                          • Nov 2015
                          • 24

                          #27
                          no zmbd sir,
                          i removed that feauture form it. it was really disappointed.

                          Comment

                          Working...