A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Run a Query using VBA without User Interface



 
 
Thread Tools Display Modes
  #1  
Old November 29th, 2009, 07:43 AM posted to microsoft.public.access.queries
Pasadena-D via AccessMonster.com
external usenet poster
 
Posts: 9
Default Run a Query using VBA without User Interface

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]));

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1

  #2  
Old November 29th, 2009, 12:29 PM posted to microsoft.public.access.queries
Kc-Mass
external usenet poster
 
Posts: 362
Default Run a Query using VBA without User Interface

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

Regards

Kevin

"Pasadena-D via AccessMonster.com" u56499@uwe wrote in message
news:9fd41e1b4b9c7@uwe...
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]));

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200911/1



  #3  
Old November 29th, 2009, 04:06 PM posted to microsoft.public.access.queries
Pasadena-D via AccessMonster.com
external usenet poster
 
Posts: 9
Default Run a Query using VBA without User Interface

Kevin,

It worked! Thanks for the help!

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

Regards

Kevin

Hello,

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


--
Message posted via http://www.accessmonster.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.