Results 1 to 4 of 4
  1. #1
    kmw is offline Novice
    Windows XP Access 2007
    Join Date
    May 2012
    Posts
    27

    visual basic question to update a record with a form

    This is what I have in the expression builder in Visual Basic. Is there a problem with this? My query works when I use it manually but not when the button from my form accesses it. Is there an issue with the order of my basic code. I also used to have a "set warnings to false" line but I took that out to see if I would even get a warning and I don't. Any ideas on where the problem could be?

    Thanks!

    Option Compare Database

    Private Sub CommandBacktoListBox_Click()


    DoCmd.OpenQuery "UPDATEALL"



    DoCmd.Requery

    DoCmd.Close acForm, "FormUPDATEFROMLISTBOX"

    DoCmd.OpenForm "FormViewListBox"


    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Is the code running at all (do the forms open/close)? If not, make sure the db is in a trusted location or that you've enabled code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    DoCmd.OpenQuery "UPDATEALL"

    This should simply display your Query named UPDATEALL.

    DoCmd.Requery

    This line Requeries the Form that it resides in.

    DoCmd.Close acForm, "FormUPDATEFROMLISTBOX"

    This closes the Form named FormUPDATEFROMLISTBOX. Is this
    the Form that this code resides in?

    DoCmd.OpenForm "FormViewListBox"

    This opens another Form.


    *************

    What, exactly, do you expect this code to do?

    What does any of it have to do with the title of your thread "visual basic question to update a record with a form?" There's nothing here related to doing anything with a Record.

    Linq ;0)>

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    My suspicion is that a query named "UPDATEALL" is probably an update query. One that updates one or more records.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Creating Buttons on a form keeps returning a visual basic error
    By Robin Banks in forum Database Design
    Replies: 1
    Last Post: 02-28-2012, 07:48 AM
  2. Visual Basic
    By kwooten in forum Queries
    Replies: 2
    Last Post: 01-25-2012, 08:22 AM
  3. Visual Basic / Acces Form differences
    By MWMike in forum Forms
    Replies: 3
    Last Post: 10-06-2010, 09:06 PM
  4. Locking form with Visual Basic
    By rev_ollie in forum Forms
    Replies: 4
    Last Post: 04-29-2010, 07:27 AM
  5. Record Value in Visual Basic
    By chrismec in forum Programming
    Replies: 3
    Last Post: 12-09-2009, 04:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums