Run a Query using VBA without User Interface

  • Thread starter Pasadena-D via AccessMonster.com
  • Start date
P

Pasadena-D via AccessMonster.com

Hello,

I have a VBA Macro that Opens an Append Query (see below), which works great,
except for the end user has to answer the following MsAccess prompts:
1) You are about to run an append query that will modify data in your table.
(They have to click Yes)
2) You are about to append 1 row(s). (They have to click Yes)

I'd rather them not have to answer either question. Instead I'd like the
Append Query to run and do what it's asked without any human intervention.
Can this be done? Please help!

VBA Macro Code:
DoCmd.OpenQuery "tblTask_List Query", acViewNormal, acEdit

tblTask_List Query SQL Code:
INSERT INTO tblTask_List ( Task_Description, Status, Area, Equipment_ID,
Due_Date, Estimated_Duration, Actual_Duration, Assigned_Workgroup,
Assigned_Person, Entered_By, Compliance_Task, Overdue_Flag, Notes,
Status_Changed_By, Status_Changed_On, Completed_By, Completed_On,
Document_Link_1, Document_Link_2, Document_Link_3, Document_Link_4, Recurring,
Recurring_Days, Recurring_Until )
SELECT tblTask_List.Task_Description, tblTask_List.Status, tblTask_List.Area,
tblTask_List.Equipment_ID, tblTask_List!Due_Date+tblTask_List!Recurring_Days
AS [Recurring Due Date], tblTask_List.Estimated_Duration, tblTask_List.
Actual_Duration, tblTask_List.Assigned_Workgroup, tblTask_List.
Assigned_Person, tblTask_List.Entered_By, tblTask_List.Compliance_Task,
tblTask_List.Overdue_Flag, tblTask_List.Notes, tblTask_List.Status_Changed_By,
tblTask_List.Status_Changed_On, tblTask_List.Completed_By, tblTask_List.
Completed_On, tblTask_List.Document_Link_1, tblTask_List.Document_Link_2,
tblTask_List.Document_Link_3, tblTask_List.Document_Link_4, tblTask_List.
Recurring, tblTask_List.Recurring_Days, tblTask_List.Recurring_Until
FROM tblTask_List
WHERE (((tblTask_List.Task_ID)=[Forms]![frmTask_List]![Task List Subform].
[Form]![Task_ID]));
 
K

kc-mass

Try this:
Run DoCmd.SetWarnings False
DoCmd.OpenQuery "tblTask_List Query", acViewNormal, acEdit
Run DoCmd.SetWarnings True

Regards

Kevin
 
P

Pasadena-D via AccessMonster.com

Kevin,

It worked! Thanks for the help!

kc-mass said:
Try this:
Run DoCmd.SetWarnings False
DoCmd.OpenQuery "tblTask_List Query", acViewNormal, acEdit
Run DoCmd.SetWarnings True

Regards

Kevin
[quoted text clipped - 37 lines]
WHERE (((tblTask_List.Task_ID)=[Forms]![frmTask_List]![Task List Subform].
[Form]![Task_ID]));
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top