Modules & VBA :: Automate Access 2007 Queries With Form For Users?
Oct 18, 2013
I've been using Access 2007 to run queries on a database where we eventually export results as separate Excel spreadsheets for individual clients. The process is quite involved, using queries to change fields from code letters to words and splitting the database up into different client tables, saving the tables under date order and with different client codes.
I now need to pass this role on to colleagues, so need to make everything as straightforward as possible.
I had thought to use a Form as the user interface, with a minimum number of buttons, however I need either the system or the user to amend the date for the initial table, then to use this new table and run a series of standard queries on it, then produce the separate tables.
I don't think I can just use macros behind the buttons, because the database name is changing each time.
I assume some parts will be too tricky to automate - it will be necessary for colleagues to follow instructions instead.....
I have designed a database which I intend to split for multi-users to access from one front end icon on a shared folder at work. I have designed a form bound to cmr record table and on it a subform to another table where cmrs activities will be saved. The form has buttons to and blank controls.
User can create a new activity entry by typing into the blank controls and pressing the save button which saves to the activity table. the edit button extracts a selected records details (selected on the subform) from the activity table and populates the blank field for a user to edit and then hit save to save changes. The delete button deletes a selected record from the activity table. I intend to have multi-users either accessing, viewing and a possibly editing the same customer at the same time. The simultaneous viewing is essential but the simultaneous editing, though not desired is inevitably going to occur.
What I would like to know is:
1. Can you lock an individual record in a table or does the whole table have to be locked. E.g If Colleague 1 is editing Cmr A's record in Table1 can he lock it so Colleague 2 can view and edit Cmr B's record in Table1
2.Can Colleague 1 access/read Cmr A's record in Table1 to retrieve details toe the form controls if Colleague 2 is viewing or editing Cmr A's record in Table1
3. If record lock is possible, how can I initiate it in my example code below.Edit activity record Code
Code: Private Sub Edit_A_Click() 'Get Data to text box control With Me.R_P_Data_P_Subfrm.Form Me.txtrID = !rID Me.txtrID.Tag = !rID Me.txtrefNo = !refNo Me.cmbrpc = !rPC
I am trying to get a feel for how Access 2007 performs regarding the ammount of concurrent users using a database.
I know there has been a lot of differing opinions about previous version and was wonder is the new version of Access (& I would guess Jet as well) is more stable with multiple users?
At work we have a terminal services setup for most of the staff which is being configured now. We have hit a snag with access security settings basically we need macros to run for relinking odbc databases and various vba functions (some run overnight so we don't want to deal with the security dialogs). We though the best way to do this would be setup trusted locations. We did this logged in to terminal server as admin hoping this would be a machine level setting but it seems to be on a per user basis.
Is there a way to set a trusted location for all users of a machine I have google and come up with nothing. The other option is enable all macros which I don't want to do.
I have been asked to create a database very quickly for a small group that needs to scan multiple pages into an Access 2007 form. They they would like all scanned documents to be converted to PDF and stored on a shared network folder which can be accessed by their group. I have tried several ideas posted but, I have been unable to get any to work correctly. Any sample of working database that the scanning portion is working? I am so involved with other projects right now that I just don't have the time to create a scanning process on the database.
Is it possible (and how...) to declare a module-specific form variable (or any variable for that matter) at the top of said module, so it doesn't need to be set at the start of each subsequent procedure?
I have a module of code specific to one form with a number of procedures, each one of which requires me to Dim / Set the form variable. It would be much neater if I could do it once at the start.
Code: Option Compare Database Option Explicit Public Sub Populate(lngParameter As Long)Dim frm As Form
I have some code set up to automate scanning from access to a specific folder on the server. I have searched the web for different codes and have not come across anything that will scan an unknown amount of documents. The best I found was the code I am currently using, that will scan up to 10 documents separately, then convert these documents into 1 PDF. This is not ideal, however, because it would require the user to scan 1 document, wait, than scan another, wait, etc. Also, the code I am currently using will only scan from the glass, not the auto feeder, and I am unsure how to change this.
Private Sub cmdCOC_Click() 'scan COC On Error GoTo Err_Handler Const DEVNAME As String = "Brother MFC-7860DW LAN" Dim ComDialog As WIA.CommonDialog
If you want to use a "DoCmd.RunSQL "INSERT INTO" command to insert data in a table and the data to insert comes from a table and a form, could this be done in one pass?
So...writing a record wit 4 values from table1 together with a additional value from a textbox in table2 as 5 values.
I have two queries, one base upon the other. I would like to combine them (If Possible) into one query so I can embed them into a form or report. I have tried without success at finding the answer on the forum as well as searching the web.
The table lists employee numbers and dates they worked. I need a count of how many employees worked each year, based upon the paycheck date, not the actual date worked. Pay check dates are two weeks apart. An extreme example, is the first pay check date of 2010 was on 1/1/2010, but all the days worked were in 2009, this would have to be included in 2010 not 2009(See the query for further date calculation understanding). Anyway, the date calculations are not the issue here.
I only have one table, so if I am not mistaken, I can't use the WHERE (SELECT... JOIN) feature. I also was unsuccessful at using SQL DISTINCT.
I am running ACCESS 2010 Tables are ACCESS 2007.
OS is Windows 7 Ultimate.
I have included a same database with the queries. qryEmployeesAnually2 is the results I am trying to achieve.
I have an access database that is used as a front-end application to a sql server 2000 database. Users have adequate permissions to access database and functionalities but a few are receiving the following error message:
How would I set up an Outlook email using a list of recipients from an Access table? I'd like to be able to run this from Access 2007 and not Outlook. However, once the email is set up, I'd like to be able to go into the email and add subject, body, etc. before sending the email.
I am creating a query to use in a Word 2007 mail merge.
For simplicity, let's say the query has three fields:
schname for school name, role for staff role, and name for the staff member's name.
The current query shows:
SchoolA, Admin, Jerry Garcia SchoolA, President, Bob Hope SchoolB, Admin, Janet Jackson SchoolB, President, Mae West
I would like a query that would show one line per school like so:
SchoolA, Jerry Garcia, Bob Hope SchoolB, Janet Jackson, Mae West
I've looked at Allen Browne's ConCatRelated function and can pull up a list of all names in a field called Expr1001, but that doesn't seem to be what I need.
I have a dilema on my hands as I can't seem to figure out the best way to accomplish this. I created a database to handle all of our letters for my department in the company. The problem I am having is that we have 26 people who could possible access the database at the same time. The letters are created using a form. (not a problem with multi-users) When someone wants to print the letter the do a search either by "Letter Date", "Provider Name", "Provider Number", or "Group Name". I set it up so either one of these search queries append data into one table called "Letter Report Information" all 38 letters get there data from this 1 table. The problem I am having is that if John and Mary try to pull different/same letters at the same time or while one is viewing their letters the data is getting pushed onto the others Letter.
Example:
Mary goes to print her Welcome letter John also goes to print his Denial letter at the same time
When John's letters show up.. the Denial letter shows up with his data, but also with Mary's Welcome letter data.
What can I do or what kind of query can i use to avoid this problem as it is becoming a very prominent issue? ::Please Help::
I have a command button on a form which loops through pages on a tab control and constructs an SQL string to insert a new record into a corresponding table (each tab has it's own separate table)
The tables are linked via a common account ID (an autonumber on a separate 'Core' table, the latest record for which is generated earlier in the code; this section creates a linked record in each of the other tables)
I've used a naming convention in each page such that each control name and it's corresponding field name in the destination table are the same (apart from the first 3 characters which I use to identify the control type, i.e. "chk", "txt" etc.)
For one of my pages, the insertion of the new record keeps failing. I've gotten it to work once or twice but only by randomly changing some of the values on the form (checking / unchecking boxes or keying data into random textboxes etc.) But I can't identify why it works sometimes and not others?
The other 3 tabs/pages insert records with no issue, every time.
I've tried debugging but I don't get any error message when I execute the constructed SQL; there are no apparent control violations and all of the relevant fields are correctly named & referenced. The only 'required' field in each table is the common Account ID, which is present, correct & not duplicated, so omitting null / empty fields or passing empty strings / values for the remaining fields shouldn't be an issue (?)
I can only assume it's a problem with a value being passed somewhere but what's stumping me is that on the other pages, it inserts the records exactly as expected (whether data has been provided or not)
Stepping through the VBA, it looks like a record should be inserted - but when I check the table, there's nothing there?
Code: Dim pge As Page Dim ctl As Control Dim strSQL As String Dim strSQLFields As String Dim strSQLValues As String
I have a table of logged entries. Each record has a date field (ValueDate) and an account identifier field (AccountID)
I also have a table of rates. Each record has the same account identifier field (AccountID), a date field (EffectiveDate) and a rate field (BankRate)
Entries can be logged for any given ValueDate. But there may or may not be a corresponding EffectiveDate in the rates table.
I need to write a query that will return all of my logged entries and the largest EffectiveDate which is on or before the ValueDate (as well as the BankRate corresponding to that EffectiveDate)
This is as far as I've gotten but it returns multiple records for each logged entry. I need one record per logged entry.
Code: SELECT tblLoggedEntries.EntryID, tblLoggedEntries.AccountID, tmp.BankRate, MAX(tmp.EffectiveDate) AS EffectiveDate FROM tblLoggedEntries LEFT JOIN (SELECT tblRates.AccountID, tblRates.BankRate, tblRates.EffectiveDate FROM tblRates) AS tmp ON tblLoggedEntries.AccountID = tmp.AccountID WHERE tmp.EffectiveDate<=tblLoggedEntries.ValueDate GROUP BY tblLoggedEntries.EntryID, tblLoggedEntries.AccountID, tmp.BankRate
I have an expression that sets an AI Buy It Now value that is 125% of AI Value and rounds it, which follows AI Buy It Now: Round(([AI Value]*1.25)/10)*10
I need to add to this expression that I only want this calculation applied if AI Values are greater than 999. But I can't figure out how to add this stipulation to the above expression. I have tried IIF but it is not working.
SELECT tblCurrencies.CcyID, tblCurrencies.Ccy FROM tblCurrencies ORDER BY tblCurrencies.Ccy;
Now - I have a separate table of balances, which is linked to the currency table by the same CcyID, and which also has identifiers to link it to other tables (e.g. AccountID)
As part of the above query, I want to return the count of unique AccountID's in the balance table for each currency. So in other words, I want to know, for each currency, how many unique accounts exist?
Each AccountID could appear one or more times in the balance table (one-to-many relationship), so I only want to count the number of unique ID's.
So I started with the following :
Quote:
SELECT tblCurrencies.CcyID, tblCurrencies.Ccy, Count(tblBalances.AccountID) AS NoOfAccounts FROM tblCurrencies INNER JOIN tblBalances ON tblCurrencies.CcyID = tblBalances.CcyID GROUP BY tblCurrencies.CcyID, tblCurrencies.Ccy ORDER BY tblCurrencies.Ccy;
But this just gives the number of AccountID's per currency (regardless of duplication within them)
I found this article which informs me that a Count(Distinct) query won't work in Access and to use subqueries instead.
I am currently creating an Access 2007 database for calculating salesperson commissions. I have a table with 5 fields I'm working with: SalesRep, SOWRep, TerritoryRep, Period and Commission. I am trying to build a query that will calculate commission for a salesperson for each record where their name appears in one of the first three fields. Each time their name appears, they get the commission listed in the Commission field for the stated Period. I have managed to do this part successfully. My problem now is that I am creating a query that will sum all of their commissions by Period. I have run into a situation where sometimes a salesperson will not appear in one of the rep fields, resulting in NULL values in the previous queries. How can I create a final query that will sum correctly even if there are NULL values returned on the previous queries?
Here is what I have so far:
November: Avg((SELECT [SumOf1/3GM$s] FROM [BaxterActualMargin1] WHERE [Period] Like "November*")+(SELECT [SumOf1/3GM$s] FROM [BaxterActualMargin2] WHERE [Period] Like "November*")+(SELECT [SumOf1/3GM$s] FROM [BaxterActualMargin3] WHERE [Period] Like "November*"))
I have a table of transactions (close to 1m records) from which I want to query totals by currency and direction (ins and outs) and then also show the proportion of the overall total for each currency. All amounts are absolute (i.e. ins and outs both represented by positive numbers)
To throw some added complexity into the mix, the transaction table records only refer to account (AccountID), which links to a separate account and currency tables.
I can query the sum totals by currency and direction (although I'm not totally happy with the SQL syntax .
I'm struggling to get the proportions per currency though? I tried adding :
Code: ((SumPayUSD+SumRecUSD)/Sum(tblTransactions.USDAmount)) AS Proportion
But it tells me that the specified field 'tblTransactions.USDAmount' could refer to more than one table listed in the FROM clause of the SQL statement.
"how to COMPACT the DB by introducing delay of 10 seconds and then close the DB".In the Database, I'm able to accomplish the "Compact" the database using the function below.
Function Compact() SendKeys "%(FMC)", False End Function
As my DB is quite huge, the Compact action takes around 10 seconds to complete.Now, i would like to Close the Database after Compacting the DB. I tried including "DoCmd.Quit" in the function. The commands in the function, closes the DB but the Compact function doesn't seem to have executed as it needs 10 seconds to complete.
Function Compact() SendKeys "%(FMC)", False DoCmd.Quit End Function
how to introduce this delay of 10 seconds and then close the DB.
How to generate an export specification file by using Access 2007. Many instructions says click on "Advance" while exporting a text file manually but unfortunately i can not find that "Advanced" option in my access software.
I am getting "Truncation Error" while importing data from Excel to access 2007. I have tried changing the format to short text but the result is the same.
I have been searching for info with users & permission levels. I have ready a lot about ULS (User Level Security) which doesnt seem to be my answer as I do not have admin rights and I believe it is not suitable with Access 2010.
Basically I have an 2010 Access database which is used by my department as a project management tool. It has various tables, forms, queries & reports, I have created a table with user names & passwords and a login form. So when the databases opens the login form is launched & the users selects their user name & enters their password, then the main menu is shown.
Everything works really well, but as the moment there is no difference between all the users. All I want to do is to be able to make one of the Logins read only, ie if the Reviewer is logged in they can see & read every form and run every report but they can not make any edits.