473,396 Members | 1,927 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,396 software developers and data experts.

How to apply code process to all forms from single onclick

Hello All,

I have created a table (CommissionStatements) in Access that will store all of our data that we import from Excel.

Certain fields of the CommissionStatements table are computed using data from a linked table (Clients) via a button that is programed with an onlcick. This button is on the CommissionStatements form that contains all the fields of that table. The code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Me!Agent1 = Me!ClientName.Column(1)
  2. Me!Agent1Percent = Me!ClientName.Column(2)
  3. Me!Agent2 = Me!ClientName.Column(3)
  4. Me!Agent2Percent = Me!ClientName.Column(4)
  5. Me.Refresh
This code does the job exactly how i want it - however because we're going to be importing 100s of records at a time, it is a hassle to go through all of the forms and click the button on every single record to compute the missing fields. Is there a way to write the code or create a macro that will apply that onclick to every single form all at once?

Or does anyone have any better ideas for this process?

Sorry if my explanation is hard to follow...

Thanks, Tim
Sep 9 '11 #1
5 1984
NeoPa
32,556 Expert Mod 16PB
It's possible - but not advised.

The best advice is for you to leave the data where it is and reference it as and when required. It's never a good idea to store the same data more than once in a database (For more on this see Database Normalisation and Table structures). That way leads to all sorts of problems as you'll see if you take a minute or two to digest the linked article. I strongly recommend it for anyone serious about database design. It will save you truck loads of problems going forward.

As I said, it's possible. You would use an UPDATE query to update all the records (or even all of a filtered set) of the table in a single statement. I can give no further details on this though, as you question missed out all the details of table and field names. I strongly suggest you don't choose this path forwards though of course.
Sep 9 '11 #2
Thank you for the response NeoPa. At this point in time we are just testing out a few different options on how to automate certain processes and this seems like the best way at the moment.

If possible I would like any help I can to get this operating...I've included table names and such below...

Source Table: Clients
Source Fields: ClientName, Agent1, Agent1Percent, Agent2, and Agent2Percent

The data that we are given to import in Access only has the client name listed, which is where the onclick update came in. The VBA code is set to automatically populate the following fields on the Destination Table: Agent1, Agent1Percent, Agent2, and Agent2Percent. Like I mentioned, the auto-populate function is already working correctly.

The destination table is labeled CommissionStatements

Please let me know if you need any other information to help me out with this! And again thank you very much for your help, it is very much appreciated.
Sep 9 '11 #3
NeoPa
32,556 Expert Mod 16PB
This isn't sounding good.

Apart from not conforming to one of the most basic tenets of database theory (normalisation) this problem also appears to want to link data together based on a name string (which apparently doesn't even exist in [CommissionStatements] by the way). Anyone without any experience at all needs only a little imagination to see the flood of problems which are bound to ensue from this. Experienced developers hardly need that of course.

I'm not going to leave you without an answer to your question, but you should interpret what I am saying as the strongest possible warning that if you treat database work as cavalierly as this it will bite you back. Absolute guarantee on that one.

Assuming for now then, that the field you forgot to tell me about in [CommissionStatements] is actually called [ClientName], you would need a query of the form :
Expand|Select|Wrap|Line Numbers
  1. UPDATE [CommissionStatements] AS tCS
  2.        INNER JOIN
  3.        [Clients] AS tC
  4.     ON tCS.ClientName = tC.ClientName
  5. SET    tCS.Agent1 = tC.Agent1
  6.        tCS.Agent1Percent = tC.Agent1Percent
  7.        tCS.Agent2 = tC.Agent2
  8.        tCS.Agent2Percent = tC.Agent2Percent
Sep 9 '11 #4
NeoPa,

My sincere apoligies for falling off the map on this one, have not had time to work on the database in the past couple of weeks. I have taken your suggestion and am using a query to match up the data and form a report instead of applying a code process within the forms. It seems to be working flawlessly, however I have run across some new issues (unrelated to this one), but I will post a new topic for it. Thanks again for all your help, it is truly appreciated.
Oct 27 '11 #5
NeoPa
32,556 Expert Mod 16PB
That sounds like a good response to me Tim. I'll look out for your new thread (which was the correct way to handle this BTW).
Oct 27 '11 #6

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

Similar topics

0
by: Lars Grøtteland | last post by:
Hello! This is an IDE question, and I can't find one IDE newsgroup. How can I enable the Apply Code Changes(alt+F10)? I tried to get into Tools-Debugging-Edit and Continue, but I'm not shure...
0
by: Lars Grøtteland | last post by:
Hello! In VC6.0 there was an option - Apply Code Changes(Alt+F10) when something changed in the code during debug. I can't find it in .NET 2003? Where is it? Has it been taken away? If this...
3
by: vj | last post by:
Please let me know how can i handle any kind of error conditions with a single (condition and continue handler). I need to catch any kind of exception thrown in the procedure with a single (...
1
by: Mike Shafer | last post by:
Hello! I was hoping to write a program that could monitor another process' controls, but I know nothing about it. So this program would spawn the monitored program, and it could grab a handle on...
6
by: milkyway | last post by:
Hello there, I have the following code (written in Javascript) for posting of a form on the client side: .... var f2 = document.forms; f2.method = "post"; f2.submit();
1
by: Trevor Fairchild | last post by:
Hello all - I've been working in VB6 for about a year and now I've moved "up" to VB.NET. I think I would have fewer problems in learning vb.net if I knew nothing about previous versions of vb......
1
by: Village | last post by:
I have installed PHP several times using tutorials and information from a book, but each time I am able to use basic functions, such as date(), but when it comes to processing forms it shows up...
1
by: sam2332 | last post by:
you drag the link into the favorits bar and when you click on it it makes a sub window i think i stole it for rollyo.com any help would be great.. <a...
21
by: DanicaDear | last post by:
I have a report named "rptHOTSTICKS_EXPIRING" based on a query named "HOSTICKS_SHIPPING_REPORT Query". The query contains these fields: ORDER_NUM (text) CUST_NUM (text) Name, address, contact...
1
by: Rohit Nayak | last post by:
Hi I want to insert single quote using VC++ but I cant able to do this. I just insert 2 single quote's which works in sql but it will not be helpfull in c b'coz it show 2 single quote in DB. I just...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.