Visual Basic 6.0 to MS Access to MS Excel

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DUNXALEARE
    New Member
    • Mar 2007
    • 21

    Visual Basic 6.0 to MS Access to MS Excel

    Hello everyone!
    I have a new assignment. I just dont know how to create a data report using ms excell.

    I need to search particular group of data/records using Visual basic 6. in MS Access and transfered this selected data in MS Excel. to generate a report.

    Please can anyone give me a tip or I'd rather say the syntax on how to edit,delete,add ,search data in ms access using visual basic 6 without using Adodc component. (you see im having problem in using adodc component and directly connecting the textbox on adodc's data field the computer prompt me operation cancelled).

    And proper way of transferring records/data from MS Access using VB to MS Excel.

    thans Folks ;)
  • Dököll
    Recognized Expert Top Contributor
    • Nov 2006
    • 2379

    #2
    Greetings, DUNXALEARE!

    I am sure it's probable and perhaps there are many ways to start.

    (1) How much time are you willing to invest taking on this project?
    (2) Do you have anything working at this point?

    Please excuse my passiveness. It'd be helpful to you if we know what you have thus far.

    You may need to get one thing working then tackle the next (i.e. VB to Access first, then Excel). It's also likely, a great tutorial will be of use if you're interested and have the time to look through.

    Welcome!

    Dököll

    Comment

    • DUNXALEARE
      New Member
      • Mar 2007
      • 21

      #3
      Originally posted by Dököll
      Greetings, DUNXALEARE!

      I am sure it's probable and perhaps there are many ways to start.

      (1) How much time are you willing to invest taking on this project?
      (2) Do you have anything working at this point?

      Please excuse my passiveness. It'd be helpful to you if we know what you have thus far.

      You may need to get one thing working then tackle the next (i.e. VB to Access first, then Excel). It's also likely, a great tutorial will be of use if you're interested and have the time to look through.

      Welcome!

      Dököll

      As of now i try to connect and manipulate the data in ms access using vb 6. but i encountered some problems like run time error because i used directly an adodc components ( the only way i know to transfer or retrieve data in access) . I guess i need to focus on connecting visual basic to ms access using other method other than adodc components, before i proceed to ms excel, is that possible?
      Im just a begginner so i know only basic ,but I will be glad if I'll learn advance or new programming techniques from you guys.

      Kind regards :)

      Comment

      • DUNXALEARE
        New Member
        • Mar 2007
        • 21

        #4
        Code:
        saves_click()
        Select Case act
          Case 2
            Select Case cond
              Case 0
                ansr = MsgBox("The employee you enter already exist. Would you like the record to display?", vbYesNo, Label)
                  If ansr = vbYes Then
                    act = 0
                    ans = txt_no(0).Text
                    epis.Recordset.CancelUpdate
                    educ.Recordset.CancelUpdate
                    family.Recordset.CancelUpdate
                    flag = False
                    saves.Enabled = flag
                    initialization
                    search
                  Else
                    epis.Recordset.CancelUpdate
                    educ.Recordset.CancelUpdate
                    family.Recordset.CancelUpdate
                      Exit Sub
                  End If
              Case 1
                ans = MsgBox("Are you sure you want to save this record?", vbYesNo, Label)
                  If ans = vbYes Then
                    educ.Recordset.MoveFirst
                    family.Recordset.MoveFirst
                    epis.Recordset.MoveFirst
                      MsgBox "You succesfully save the data", vbOKOnly, Label
                      txt_no(0).Visible = True
                  Else
                    GoTo 4
                  End If
              Case Else
                'act = 2 and cond <> 0 or 1
            End Select
          Case 3
            If cond = 1 Then
              MsgBox "The record's identification code has been modified. System failed to update.", vbCritical, Label
              epis.Recordset.CancelUpdate
              educ.Recordset.CancelUpdate
              family.Recordset.CancelUpdate:
              epis.Recordset.MoveFirst
              educ.Recordset.MoveFirst
              family.Recordset.MoveFirst
            Else
              'act = 3 and cond <> 1
            End If
          Case Else
            'act <> 2 or 3
        End Select
        
        act = Empty
        acts = Empty
        Form_Load
        
        4:
        End Sub
        That is one part of my coding and it focus on saving. it runs smoothly 10 to 20 times, until i encounter a runtime error "operation cancelled"
        Last edited by DUNXALEARE; Apr 1 '07, 11:29 PM. Reason: MISSED SYNTAX

        Comment

        • Dököll
          Recognized Expert Top Contributor
          • Nov 2006
          • 2379

          #5
          Originally posted by DUNXALEARE
          As of now i try to connect and manipulate the data in ms access using vb 6. but i encountered some problems like run time error because i used directly an adodc components ( the only way i know to transfer or retrieve data in access) . I guess i need to focus on connecting visual basic to ms access using other method other than adodc components, before i proceed to ms excel, is that possible?
          Im just a begginner so i know only basic ,but I will be glad if I'll learn advance or new programming techniques from you guys.

          Kind regards :)
          All is probable and the possibility relies on your patience. You will get it. You can achieve as you please D...

          Perhaps adodc is what you should tackle first, with minimal coding.

          Try searching this forum using "DataReport Adodc1". You'll find a number of posts on this. Continue with Excel afterwards. How's that for a deal?

          Comment

          • Dököll
            Recognized Expert Top Contributor
            • Nov 2006
            • 2379

            #6
            Originally posted by DUNXALEARE
            Code:
            saves_click()
            Select Case act
              Case 2
                Select Case cond
                  Case 0
                    ansr = MsgBox("The employee you enter already exist. Would you like the record to display?", vbYesNo, Label)
                      If ansr = vbYes Then
                        act = 0
                        ans = txt_no(0).Text
                        epis.Recordset.CancelUpdate
                        educ.Recordset.CancelUpdate
                        family.Recordset.CancelUpdate
                        flag = False
                        saves.Enabled = flag
                        initialization
                        search
                      Else
                        epis.Recordset.CancelUpdate
                        educ.Recordset.CancelUpdate
                        family.Recordset.CancelUpdate
                          Exit Sub
                      End If
                  Case 1
                    ans = MsgBox("Are you sure you want to save this record?", vbYesNo, Label)
                      If ans = vbYes Then
                        educ.Recordset.MoveFirst
                        family.Recordset.MoveFirst
                        epis.Recordset.MoveFirst
                          MsgBox "You succesfully save the data", vbOKOnly, Label
                          txt_no(0).Visible = True
                      Else
                        GoTo 4
                      End If
                  Case Else
                    'act = 2 and cond <> 0 or 1
                End Select
              Case 3
                If cond = 1 Then
                  MsgBox "The record's identification code has been modified. System failed to update.", vbCritical, Label
                  epis.Recordset.CancelUpdate
                  educ.Recordset.CancelUpdate
                  family.Recordset.CancelUpdate:
                  epis.Recordset.MoveFirst
                  educ.Recordset.MoveFirst
                  family.Recordset.MoveFirst
                Else
                  'act = 3 and cond <> 1
                End If
              Case Else
                'act <> 2 or 3
            End Select
            
            act = Empty
            acts = Empty
            Form_Load
            
            4:
            End Sub
            That is one part of my coding and it focus on saving. it runs smoothly 10 to 20 times, until i encounter a runtime error "operation cancelled"
            Nice code, keep it handy for later usage. Get VB to Access working first. See one of my posts on DataReport? Please search, you'll save yourself some effort...

            Comment

            • DUNXALEARE
              New Member
              • Mar 2007
              • 21

              #7
              Originally posted by Dököll
              Nice code, keep it handy for later usage. Get VB to Access working first. See one of my posts on DataReport? Please search, you'll save yourself some effort...
              THANKS FOLKS :)
              I'll definitely look for that report

              Comment

              • DUNXALEARE
                New Member
                • Mar 2007
                • 21

                #8
                Originally posted by Dököll
                All is probable and the possibility relies on your patience. You will get it. You can achieve as you please D...

                Perhaps adodc is what you should tackle first, with minimal coding.

                Try searching this forum using "DataReport Adodc1". You'll find a number of posts on this. Continue with Excel afterwards. How's that for a deal?

                heyo i've searched your post about connectiong visual basic to ms access.
                your forum with "Yoda". I guess you still remember him.
                the splash and login is working but in "about" I'm Stucked.

                i folow your coding there and i've got the same error Yoda was saying
                " Compile Error -Undefined User-Defined Type not Defined"
                I follow the whole discussion between you and yoda about it.

                did you found solution about that error.
                kind regards

                DUNXALEARE :)

                Comment

                • Dököll
                  Recognized Expert Top Contributor
                  • Nov 2006
                  • 2379

                  #9
                  Originally posted by DUNXALEARE
                  heyo i've searched your post about connectiong visual basic to ms access.
                  your forum with "Yoda". I guess you still remember him.
                  the splash and login is working but in "about" I'm Stucked.

                  i folow your coding there and i've got the same error Yoda was saying
                  " Compile Error -Undefined User-Defined Type not Defined"
                  I follow the whole discussion between you and yoda about it.

                  did you found solution about that error.
                  kind regards

                  DUNXALEARE :)
                  A solution was indeed, found, and Yes Yoda's a good man. A gentle person of our group searched and found a solution to the error and posted a link for the Scripts Forum. Incidentally, the code works on my machine, deals with the access version, it seems...

                  Please look at last few posts, 11th, or 12th position of that discussion. Let me kow how it turns out :-)

                  Still, I think you need DataReport, as Yoda's had to do with communicating with Access...
                  Last edited by Dököll; Apr 6 '07, 12:49 AM. Reason: Added remark

                  Comment

                  • Dököll
                    Recognized Expert Top Contributor
                    • Nov 2006
                    • 2379

                    #10
                    I'll fetch for Adodc1 DataReport, and will push it forward for all to see, remember to keep an eye on Adodc1 D, ok...

                    Comment

                    • DUNXALEARE
                      New Member
                      • Mar 2007
                      • 21

                      #11
                      Originally posted by Dököll
                      I'll fetch for Adodc1 DataReport, and will push it forward for all to see, remember to keep an eye on Adodc1 D, ok...
                      sure hope to see it very soon. :)

                      Comment

                      • Dököll
                        Recognized Expert Top Contributor
                        • Nov 2006
                        • 2379

                        #12
                        Originally posted by DUNXALEARE
                        sure hope to see it very soon. :)
                        Good, hopefully user-friendly:-)

                        Comment

                        Working...