Access VBA to find & move recurring value - ms-access

Good Morning,
I'm fairly new to Access VBA and I've been trying to find a solution to a problem:
I've created a form from which users upload an excel file to a database. File open prompt appears, user selects the file, temp table gets created and data gets pulled to this table. From there a set of macros populate the required fields and push the complete set to a perm table and then temp table gets deleted. Now I would like to take it a step further and try and count how many times a value has been uploaded to the table...
Lets say that the value appears in the table twice already, then if user tries to upload the same value for the third time it will be uploaded to a different table. Bear in mind that the file which users will upload may contain values that will be uploaded for the first, second, third, etc. time.
Do you have any suggestions or solutions to my problem? Is it even possible? If yes then how can I make Access to distinguish which records are being uploaded for the first, second, third, etc. time and follow appropriate paths?
I've been scouting the internet for several days now, but no one seems to have such issue.
Thank you in advance for replies.

I'm not sure I follow. You are essentially trying to prevent inserting duplicate data to a production table and if a duplicate is encountered at the record to a different table?

Related

After Delete Data Macro

I am running into a problem doing something very simple with MS Access data macros. When a record row is deleted from T_Roster, I want it copied to t_Deleted. I know there are a plethora of other and better ways to accomplish this however, the requirements for this are such that a data macro is required. The end user/manager does not want me to add columns to the roster table or use a form (both of which I had initially suggested). That said, I have been scouring the internet for a solution and see that this question has been answered however, I have not been able to get the simple macro to work on my end. I have finally worked up the nerve to ask the question here again so please be kind.
There are only 2 tables in this DB. t_Deleted and T_Roster
I have attached a screen shot of what my current macro looks like. In the interests of keeping things simple, I only want the "OCIO_Name" to copy over for now. I assume that if this test works, the rest of the fields will not be an issue.
Table properties are as follows:
T_Roster Table Properties
t_Deleted Table Properties
Macro in T_Roster:
T_Roster AfterDelete Macro
Can anyone tell me what is wrong with what they see?
edit Does not work means that t_Deleted is not updated when I delete a record from T_roster.
Fields set as required will prevent creating new record unless data is provided for them. Either don't set as required or provide data.

Program to help split and manage 2,000 column excel

I am building a web application that will run off of data that is produced for the public by a governmental agency. The issue is that the csv file that houses the data I need is a 2,000 column beast of a file. The file is what it is, I need to find the best way to take it and modify it. I know I need to break this data up into much smaller tables within MySQL, but I'm struggling with the best way to do this. I need to make this as easy as possible to replicate for next year when the data file is produced again (and every year after). I've searched for programs to help, and everything I've seen deals with a huge amount of rows, not columns. Has anyone else dealt with this problem before? Any ideas? I've spent the last week color coding columns in excel and moving data to new tabs, but this is time consuming, will be super difficult to replicate and I worry it leaves me open for copy and paste errors. I'm at a complete loss here!
Thank you in advance!
I suggest that you use functions in excel to give every column an automatic name "column1", "column2", "column3", etc.
After that import the entire csv file into MySQL.
Decide on which columns you want to group together into separate tables. This is the longest step and no program can help you manage this part.
Query your massive SQL table to get just the columns you want for each group. Export these queries to CSV and then import them as new tables in your database.
At the end, if you want, query all the columns you didn't put into separate groups. Make this a new table in the database and delete the original table to save on storage space.
Does this government csv file get updated and republished in the same format every time? If so you'll need to write a script to do all of the above automatically.

How to edit DB file and insert multiple records in one of its table?

I've been working on some of my projects, and I am feeling stuck because my software takes 1 or 2 hours to load those 10,000 records (basically it goes through lengthy way and I want to skip it).
Luckily I know that the software uses .db file to save fetched records and I am sure that if I can put my custom list in table of .db file, it will show up in software without need to go through lengthy process. I used some .db viewer and editor and through those tools, i was able to see my desired table (in which there are records), and there was "Insert record" option too, but imagine that I want to put 10,000 records and inserting record one by one is way huge time consuming.
Therefore, I want to edit one table of that .db file and insert custom records (multiple) in one or few clicks rather than 10,000 clicks.
.db file is located in AppData > Roaming ... etc
Is there any way to achieve? For your information, I use Windows 7 operating system.
thanks for your interest. I was able to insert multiple records through Insert SQL query and now everything is working perfectly.
Thanks!

The best way to manage database (ACCESS)

What is the best way to organize a big database.
The way it works is that only I am allowed to touch or modify the database but interns help sometimes to collect data, we used to have the whole system excel based, back than we had the macro which by choosing 2 files it will integrate and mark in colors the changes.
How can I create something friendly to use which will update by pressing a button and also will show changes!! I am familiar with the update query, however:
it doesn’t track any changes.
I want to know other options.
To sum up the way of processing is:
I have the database and I need to split some data to smaller files so other employees will work on.
Then I will collect the files and integrate with the existing database, but since we are all human mistakes can happened that’s why I want to be able to track easily changes.
The updates are going to happen often. When I will give the intern a temp. table The possible changes are for example: address, phone number, price, they will do those researches based on current data which they will find online which information has been changed, and they will change the info which is on the temp. table, That is why I want to be able to know what exactly did they found out. Lets say if Product A (product ID1234) used to cost 10$ and today its 12$ from the same supplier. I just want to know and to see that the price for product ID1234 has been changed. Not only to have it updated to the back end database. For quality assurance I need to track which new input they did in relation to the product ID. (some times input by someone else which was done in wrong format or wrong column could affect big time on the quality of the reports)
So this was the explanation for what I need the reports
So in order to make those temp. tables, I want to create a form for it that by choosing region, category etc. and then clicking on a button it will automatically select the relevant records from the database, create a new table/access-file and then copy the selected records to the temp. table. So someone else could work on it...
Next thing is that it would be nice to know how can I create a template for tables, by template I mean to standardize by validation rules. some fields I'd like to have dropbox menu, some fields ready mask for phone number.... etc.
Final part, after they made the changes and saved the file (the temp. table which they were working on), I want to be able to update the back-end database via clicking on a button...
Looking forward to get the best solution!
Thanks in advance J
Michael
Okay for the temp tables thing:
why not split your database in a backend part (having all the tables) and a frontend part which contain the forms and tables the interns need? I'm guessing mostly it is going to be the same so you can even create multiple different frontend's to give to different interns incase they need other tables. There are a lot of articles out there about splitting a database and linking tables.
Then the thing about the record changes not sure is this is what your looking for but it could help, i haven't used it myself so not sure what it exacly does. But this may help you a bit.
http://support.microsoft.com/kb/197592
I would consider taking a look at the BeforeUpdate event for the form. You can trap the old and new values of textboxes if the form is bound to a table. You could loop through all the controls on your form and check for Me.Control <> Me.Control.OldValue. If they don't match, write both values to an auditing table so you can go back and check whenever you want to. I would include the following fields in your auditing table:
ChangeDate
TableName
ControlName
OldValue
NewValue
Then you can query that table any time you want to see what has changed.

How to communicate between two instances of open MDB with same form?

In VBA (Access 2000) is there anyway to send information to a form between two open instances of the database?
For example :
User 1 has an instance open of DB.MDB on his PC and has FormOne open. User 2 has another instance of DB.MDB open on her PC and has FormOne open.
Can User 1 maniuplate the contents of a textbox on User 2's FormOne instance (ie. sending a message similar to a chat client)?
You could store data to a table and update the form or subform on a timer.
Like Remou, I think the table method is as you are going to get. You can optimize the querying by maintaining a one-record table that has the value of the last update. Then have your timer form check to see if the value has changed since the the timer last triggered, this will tell the timer to check the chat table.
In the alternative you can have records deleted as soon as they are read to keep the table small.
You will find that all the record creation/deletion will bloat your database though, so be sure to compact it regularly.
Lastly if all users have access to a shared drive you could just store the messages in a text file instead of a table.
Another issue is of course eavesdropping (with tables or files). You could minimize this by:
Obfuscating/encrypting the text before it is written and deobfuscating it when it is read. Deleting the record as soon as it is read by it's target.
Hiding the file/table. For files use: SetAttr myFile, vbSystem or vbHidden
For Tables prefix the table name with USys_ and make the table hidden.
All that said, it's still going to be a sorry substitute for a chat client. It will slow down the database and possibly slow down the shared drive. I would think long and hard about why I need this, and if it's really the best approach.