473,326 Members | 2,173 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,326 software developers and data experts.

Can I run VBA Code whenever a particular table is opened?

I'd like to attach VBA code to a table the way i can with reports and forms .... I have not been able to figure out a way to do this ....

Is this something that can be done ? or am I searching in vain?

thanks
Apr 5 '07 #1
8 2160
Corster
36
In Access, you can create forms, then click the code button. If you've gotten this far then your form, as long as you've gone through the wizard to get it to interact with fields from your database, will run your code and constantly update your tables.
You can use SQL queries in your controls' RowSource and ControlSource etc properties, or wrap them in quotes in your code for the controls' properties.

I'm not entirely clear as to what your question is though, so I hope this has helped.
Apr 5 '07 #2
I'm not trying to interact with a table through a form .... but trying to attach a piece of code if someone tries to open the table itself .....

several people have admin rights on the system .... but a few of those shouldn't and tend to meddle ... i have some code that would help log what theyre doing, but i'd prefer to attach it to the table itself .... but i don't know that there is a "open table" proceedure to which i can attach the code
Apr 5 '07 #3
Denburt
1,356 Expert 1GB
I'd like to attach VBA code to a table the way i can with reports and forms .... I have not been able to figure out a way to do this ....

Is this something that can be done ? or am I searching in vain?

thanks

I am sure I could pull it off but why? I think you should look over Corster post, using a form is much more sensible, and if you set it to appear as a Datasheet it will look and act much like your table.
Apr 5 '07 #4
Denburt
1,356 Expert 1GB
but i don't know that there is a "open table" proceedure to which i can attach the code
No direct procedure but give me a couple of minutes and I will see if my idea works.
Apr 5 '07 #5
thanks .....

my reasoning is this: there are people who have access to access tables who shouldn't, i cannot (as ive been told by my manager) lock their access to the tables ....

but i can if i can attach some code minimize the damage that they do ....

while i like to use forms for accessing tables and i provide them ...some of the semi advanced users blunder in and change what they shouldnt
Apr 5 '07 #6
Denburt
1,356 Expert 1GB
Something you may consider (just hit me) Hide the Database window. In your main menu you can add a procedure to trap keystrokes and prevent them from using F11 to show the DB window and use your own KeyCode combination to view the DB window...

However here is what I have for you so far if you want to take this approach.
Alright, I know this may be a bit crude and it will not work if they open a table in design view. However if they just click to open a table this will work.

What I did was create a dummy field, named whatever then use the lookup portion to make this work. My Rowsource I just added a select statement any select statement or table it will never get used. Then in the rowsource type I set to "Fragged" which is the name of my function.


Expand|Select|Wrap|Line Numbers
  1. Function Fragged(ctl As Control, lngID As Long, lngRow As Long, _
  2. lngCol As Long, intCode As Integer) As Variant
  3. MsgBox "Your user name has been recorded and reported!",VBCritical
  4.      Application.Quit
  5. Bye_Fragged:
  6.       Exit Function
  7.  
  8. Err_Fragged:
  9.    ' MsgBox Err.Number & "    " & Err.Description, vbOKOnly + vbCritical, "Fragged"
  10.     Fragged = False
  11.     Resume Bye_Fragged
  12.    End Function
  13.  
Can you say good bye... :)
You can even put something in there that will record this users actions.
Apr 5 '07 #7
Nice and Dirrrrty .....

Thanks so much for your help
Apr 5 '07 #8
Denburt
1,356 Expert 1GB
My pleasure! :)
Apr 5 '07 #9

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

Similar topics

22
by: Martin MOKREJ© | last post by:
Hi, I'm looking for some easy way to do something like include in c or PHP. Imagine I would like to have: cat somefile.py a = 222 b = 111 c = 9
1
by: Brad H McCollum | last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the MSDE version of SQL Server as the back-end (it's a program for a really small # of users --- less then 3-4). I'm trying to...
5
by: et | last post by:
How do I get Visual Studio to quit modifying the layout of my code? In Tools, Options, Text Editor, All Languages, Tabs, I have set to None. In HTML/XML, I have tabs set to none; all automatic...
9
by: WRH | last post by:
Hello I am new to asp but I made some Jscript functions which work fine. The functions contain some strings used as a registration key for some apps. It is important that these strings not be...
4
by: jason.awlt | last post by:
Greetings, I recently being bugged by the following error on my DB2. SQL0902C SQLSTATE = 58005 Reason Code = 14 This error comes out everytime i tried to insert some record to a table...
4
JodiPhillips
by: JodiPhillips | last post by:
MS Access2000 Hi everyone, I've searched the forums for an answer to this question and nothing jumps out at me. When a database is opened I want to automatically run code (at start-up) that...
29
by: Neil | last post by:
I would like to compact on close only if the database size goes over a certain amount, rather than each time. Thus, I'd like to check the file size and then perform the compact through code as the...
11
by: Gord | last post by:
When I open a certain report, it runs some code that generates the records that will be displayed in that report. This works fine. When I go to print preview the report it appears that the code...
1
by: japss | last post by:
Hi I am experiencing a strange problem binding my web project from Visual Studio (VB.NET) to Visual Source Safe. Whenever I open the solution file, it retrieves files from VSS and overwrites my...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.