473,409 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

MS Access - Run Query with button

Hello all, I hope this is a simple one.

I'm looking to run a query that I have stored with the click of a button.

I know that there is an 'Open Query' action available in the macro setup for the button, but I do not want to open it. I'd just like to rerun it in the background each time I hit the button.

Is there a way to do this without displaying the query for the user to see?

Thank you for any help you can give me,

Sam
Access Newbie

Additional Notes: the query is a SELECT query with criteria based on a selection within my form. I have already created it, and it's working correctly. I just don't want to view it when I hit the button, that's all :)
Nov 18 '13 #1
4 3446
MikeTheBike
639 Expert 512MB
Hi

I don't understand why you would want to open a select query without viewing it. When (how) dose it get closed before you hit the button again?
Nov 18 '13 #2
Hello Mike, thanks for your response.

The query itself is basically used to calculate quote revisions. It's bit of a faff but I'll do my best to explain it.

I have two tables. One for Projects, another for Quotes. They are both linked so that I can attach quotes to a project number. I am not using the Quote Table ID as a reference because it is an autonumber field and I could end up with something like:

Project 100 - Q1
Project 100 - Q32

So instead, I'm using a normal number field as the reference, and I use the query to return the quotes that exist for the specified project, then use a basic "count + 1" calculation to give each new quote the proper increment.

I have that part all working fine, it's just that I am having to manually re-run the query each time (and close it) when I select a different project, and I'd like to be able to do that automatically and in the background preferably.

I hope that offers some clarity. I'm still fairly new to Access and learning as I go, I apologise if it's not entirely clear.

Cheers!
Sam
Nov 18 '13 #3
MikeTheBike
639 Expert 512MB
Well I think I know what you are trying to do, but it is also possible that you DB design may need tweeking.

On the basis that doese not, then the way I would do it (have have in similar circumstances) is to either write s function to return the next sequential number or use DMax() +1 something like this

Expand|Select|Wrap|Line Numbers
  1. Dim NextIndex As Long
  2.     NextIndex = DMax("CountFieldName", "QuotesTableBleName", "QuoteID = " & FormControlWithProjectID) + 1
This code would be behind the button, next index can then be used in an append query or to populated a form control.

This could also be done automatically as soon as the 'PrijectID' is available (on Current perhaps!?).

HTH

MTB

ps Having troubl getting the code tags to work !!??
Nov 18 '13 #4
Ah that's a good idea! I'll give that function a try tomorrow and we'll see if it does the trick, if not, I may have to take a closer look at the DB design as you suggested. I'll update this tomorrow.

Thank you for your help Mike, have a good evening.

Sam
Nov 18 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Art | last post by:
Hi, Can anyone point me to an example of how I would execute a query I've created in an Access DB. I've copied the SQL down to my VB.net application and that works fine, but it's ugly. I'd like...
2
by: johncontact | last post by:
I am using vb6 on xp and i want to load an access query from a command button. I am new to vb and i need help. My access database is called Garage and the query is called CARS. Any help please
12
by: zwasdl | last post by:
Hi, I'm using MS Access to query against Oracle DB via ODBC. Is it possible to use HINT in Access? Thanks, Wei
3
by: Idlemind23 | last post by:
Ahoy! I'm hoping for some help on what (I believe) should be a simple task. I have a form with a button. I would like that button to have a caption with a date. That date should be pulled out...
3
by: austin1539 | last post by:
I am trying to run an Access query from Excel. The query, called "ProdActs1" works in Access and is run from using information from a table called "Queries". When a button is clicked in Excel, data...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
6
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one...
0
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
5
by: Tony | last post by:
I am continuing to develop an Access 2007 application which was originally converted from Access 2003. In Access 2003 I was able to disable the Access Close button in the top righthand corner of...
0
by: miss D | last post by:
Hi, I have Access button with this command: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "MYS", "C:\SERVICE AWARD PROGRAM\REPORTS\reports.xls", True, "MYS" It transfer...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.