Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Posts
    23

    Unanswered: Run Update Query From Form

    I have an update query I’d like to run from a form.

    The query’s criteria cell is already setup. What I need is a way to fill in the “Update To:” cell and run the query from the form.

    A toggle button on the form would run the query.

    Let’s say the query’s name is qryUpdate. The field the query will update is tblStanding.TripDate. The form is frmSelection and the input control that will hold the value to be sent to the query is named frmSelector.ctrDaily.

    Oh, and if it’s not already obvious, the value to be sent will be a date, like 4/1/2010.

    Is there VBA code that will accomplish this?

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    You can refer to a form control in the update to section.

    UPDATE TableName
    SET FieldName = Forms!FormName.ControlName
    WHERE...
    Paul

  3. #3
    Join Date
    May 2010
    Posts
    23
    Thanks, Pbaldy.

    Seems to work fine from the query. Any chance of running it in VBA?

    With VBA I wouldn't get the "you're about to update...." msgbox.

  4. #4
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Well, you would still get the warnings but you can code around it. Look at OpenQuery and SetWarnings in VBA help. Normally I would recommend the Execute method but I don't think it can handle the form reference.
    Paul

Posting Permissions

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