Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

MS Access - Question

Thread Tools
 
Search this Thread
 
Old 16 August 2007, 10:10 AM
  #1  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Question MS Access - Question

Hi There,

I have a *make table* query (that works well) but I wish to enhance this by having a pop up message (once executed) that warns the user that something must have been done before the query is run.

Is this quite easy, and how do I do this ?
Thx.
Old 16 August 2007, 12:16 PM
  #2  
T4molie
Scooby Regular
 
T4molie's Avatar
 
Join Date: Dec 2002
Location: Dum dum de dum....
Posts: 2,617
Likes: 0
Received 0 Likes on 0 Posts
Default

Do you mean when the user selects to run the query it pops up the message prior to executing?
Old 16 August 2007, 12:16 PM
  #3  
T4molie
Scooby Regular
 
T4molie's Avatar
 
Join Date: Dec 2002
Location: Dum dum de dum....
Posts: 2,617
Likes: 0
Received 0 Likes on 0 Posts
Default

Also what version of access are you using?
Old 16 August 2007, 12:34 PM
  #4  
bob269
Scooby Regular
 
bob269's Avatar
 
Join Date: Mar 2003
Posts: 2,654
Likes: 0
Received 1 Like on 1 Post
Default

I take it you would want to check certain criteria before executing the query, then if it passes run the query, if it fails the test then prompt the user to tell them what needs doing then quit?

Little more info needed.
Old 16 August 2007, 01:19 PM
  #5  
J4CKO
Scooby Regular
iTrader: (1)
 
J4CKO's Avatar
 
Join Date: Jan 2003
Posts: 19,384
Likes: 0
Received 1 Like on 1 Post
Default

Put it on a button, put some code behind it,

then use msgbox to put up a dialog, you can alter the parameters to display warnings and different buttons, you can then deal with the outcome in code.

docmd.runsql to run the query, you can run the query direct or paste the SQL in, this runs a maketable query in a quick and dirty I was doing

[Status].[Caption] = "Extracting Injurynat"
DoEvents
Set qry = db.QueryDefs("Extract Injurynat")
qry.Execute
[Status].[Caption] = "Injurynat Extracted"
DoEvents


so, google for msgbox and use a version of the code above, that should do the trick.
Old 16 August 2007, 01:40 PM
  #6  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Post

Version of Access is 2003 SP2
(i'm at home now, so i can't check this).

"Do you mean when the user selects to run the query it pops up the message prior to executing?"
Yes - the pop up message should be the first thing that happens.

A "continue? Y/N" message would be ideal.

Yes - the query runs (and makes a table)
No - the query stops.


I've thought about using a button on forms and/or a macro, but users (ie my boss) my run the macro direct from the *query* screen. Hence the need for the message.

Thx.
Old 16 August 2007, 02:38 PM
  #7  
bob269
Scooby Regular
 
bob269's Avatar
 
Join Date: Mar 2003
Posts: 2,654
Likes: 0
Received 1 Like on 1 Post
Default

Something like this

Code:
Dim strMsg As String, strTitle As String
    Dim intStyle As Integer
   Dim stDocName As String
   
    strMsg = "Have you done such and such before continuing?"
    intStyle = vbOKCancel
    strTitle = "Query Maketable"
    
Response = MsgBox(strMsg, intStyle, strTitle)

If Response = vbOK Then    ' User chose Ok.
       
    stDocName = "Query Name To Run"  ' Name of Your Query
    DoCmd.OpenQuery stDocName, acNormal, acEdit
         
Else    ' User chose Cancel.
   Exit Sub
End If
Create a button on a form, and paste the code in to the on click expression
Old 16 August 2007, 02:50 PM
  #8  
bob269
Scooby Regular
 
bob269's Avatar
 
Join Date: Mar 2003
Posts: 2,654
Likes: 0
Received 1 Like on 1 Post
Default

Originally Posted by velohead66
I've thought about using a button on forms and/or a macro, but users (ie my boss) my run the macro direct from the *query* screen. Hence the need for the message.

Thx.
You can disable access to the tables/queries etc and run everything thru a front end menu to limit what users are doing.
Old 16 August 2007, 09:30 PM
  #9  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Question

Originally Posted by bob269
You can disable access to the tables/queries etc and run everything thru a front end menu to limit what users are doing.
How do you do that, pls.
Old 17 August 2007, 08:09 AM
  #10  
bob269
Scooby Regular
 
bob269's Avatar
 
Join Date: Mar 2003
Posts: 2,654
Likes: 0
Received 1 Like on 1 Post
Default

Tools / Database Utilities / Switchboard manager

this sets up your menu, just add your form and any other forms / reports you want users to be able to run.

Then

Tools / Startup

Make sure the Display/Page Form says switchboard, and then deselect the Display Database Window.

If you wish to get access to the database window yourself for editing, you can bring it up by pressing F11.
Old 17 August 2007, 09:36 AM
  #11  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Default

Thanks, I'll try the Form trick.

But just to conclude, I therefore assume that it is not possible to have a pop up message directly within the query.
I assume that it has to be part of a procedure, in which running the query is the second part.

Is this correct ?

I notice you can view the SQL code of the query, but assume that you cant include a bit of VB code in there ? It would be nice if you could !!
Old 17 August 2007, 09:48 AM
  #12  
bob269
Scooby Regular
 
bob269's Avatar
 
Join Date: Mar 2003
Posts: 2,654
Likes: 0
Received 1 Like on 1 Post
Default

I dont think you can add to the query before it executes, but i only know enough vba/access to get by

you could try posting or browsing on here

MrExcel Message Board :: Index
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JimBowen
ICE
5
02 July 2023 01:54 PM
KAS35RSTI
Subaru
27
04 November 2021 07:12 PM
TylerD529
General Technical
2
09 October 2015 01:53 AM
Brzoza
Engine Management and ECU Remapping
1
02 October 2015 05:26 PM
Littleted
Computer & Technology Related
4
25 September 2015 09:55 PM



Quick Reply: MS Access - Question



All times are GMT +1. The time now is 12:56 PM.