Results 1 to 9 of 9

Thread: Help with ADO-Access, please [RESOLVED]

  1. #1

    Thread Starter
    Junior Member Jethro Tull's Avatar
    Join Date
    May 2005
    Location
    Buenos Aires - Argentina
    Posts
    31

    Help with ADO-Access, please [RESOLVED]

    I'm newbie with ADO. Probably too conservative with VB5 methods (now I'm using VB6), I was using DAO till rencently.

    I have a problem (I think a stupid and simple problem): if I'm creating a new record, I can't avoid this to be saved in the database. It is, I can't cancel.

    Example: I'm filling data in a form, I decide not to add it to the base, but any action I do updates the base with the data.

    I'm linking the form objects with the recordset fields and ending the cmdNew_Click() sub with rsXXXX.AddNew.

    Thanks
    Last edited by Jethro Tull; May 12th, 2005 at 12:59 PM. Reason: Resolved

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help with ADO-Access, please

    Can you post some code? Are you using the ADO Data control? There are events that you can add to trap the before
    updating event and cancel it out.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member Jethro Tull's Avatar
    Join Date
    May 2005
    Location
    Buenos Aires - Argentina
    Posts
    31

    Re: Help with ADO-Access, please

    Well, I have a "New" command button to add records a database. I'm using all code, not using the ADO Data control.

    VB Code:
    1. Private sub cmdNew_Click()
    2.   txtTitle.Text = ""
    3.   txtAutor.Text = ""
    4.   txtPub.Visible = False
    5.   cmbPubs.Visible = True
    6.   rsBooks.AddNew
    7. end sub

    I've resolved the problem by making enable=true in all of the other command buttons (navigation and delete, edit, save and close, all coded), but it's an artifficial solution and not a real solution.

    Thanks for the answer, and sorry for my english.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Help with ADO-Access, please

    I believe that is not an artificial solution as you said because you really have to prevent users from doing anything else except save or cancel (not movenext, movefirst, etc.....) when you are adding a new record....

    Anyway there is the .CancelUpdate that you could use to cancel the addition of the previously saved record..... I havent got the chance to use it anymore because mostly now I am using action queries (Insert Into, Update, Delete) in my data manipulation....
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help with ADO-Access, please

    .AddNew should be used in your app in a way that they click Add command button and that clears the textboxes, etc.
    Then after they fill in all the controls with data, they click an "Update" command button. This is where you place your .AddNew along
    with setting the fields data with their correcponding controls data and then do the .Update. You can have a "Cancel Update" command
    button too. That would do the .CancelUpdate method previously posted.

    Ps, I'm glad to see that your not using bound controls.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Help with ADO-Access, please

    This maybe RobDog888 is suggesting....

    VB Code:
    1. Private Sub Add()
    2.     textbox1 = vbNullString
    3.     textbox2 = vbNullString
    4.     ....
    5.     textbox1.SetFocus
    6. End Sub
    7.  
    8. Private Sub Save()
    9.     AdoRecordset.AddNew
    10.     AdoRecordset.Fields("Field1").Value = textbox1
    11.     AdoRecordset.Fields("Field1").Value = textbox1
    12.     .....
    13.     AdoRecordset.Update
    14. End Sub
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  7. #7

    Thread Starter
    Junior Member Jethro Tull's Avatar
    Join Date
    May 2005
    Location
    Buenos Aires - Argentina
    Posts
    31

    Re: Help with ADO-Access, please

    Thanks. I can't believe wht silly errors I'm doing. The dee-u solution is what I was using in DAO. Maybe I was too confused but ADO in programmings terms are not so different to DAO that I was thinking.

    Thanks a lot.

    RobDog888: I never use the bound controls. I alwasy want to control my code

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Help with ADO-Access, please

    Cool! Dee-u got it correct. Yes, DAO and ADO are very similar but ADO is better when your connecting to Access from another program.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Junior Member Jethro Tull's Avatar
    Join Date
    May 2005
    Location
    Buenos Aires - Argentina
    Posts
    31

    Re: Help with ADO-Access, please

    Thanks, so I modify the title of this tread as [Resolved]

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