Using a query within a form - Microsoft access - forms

Hi I have a form that has a text box in the header and when the user enters the farmer Code into the text box the relevant record is displayed.
I am using the following criteria in the query within my Form Cotton12:
Like [Forms]![Cotton12].[2012]
Now I have 2 tables Table Cotton12 and Table Cotton11. They contain a database of farmers, from the year 2012 and 2011. Sometimes the data is the same sometimes it is not. For example Farmers are given farmer codes, however due to incorrect capturing of data different farmers have been given different codes throught over the years.
What I would like to do is in the same form, have the user enter in a farmer code and data from the 2012 table come up and the data from 2011 table come up so they can be compared and if that code is not in one of the tables the fields relating to that table stay blank.
For E.g. the form might look like this.
2012
Farmer Name
Acreage
Yield Estimate
2011
Farmer Name
Acreage
Yield Estimate
Your help would be much appreciated.

There are 2 potential ways to do this.
The more complex way is to create 2 sub-forms, and link them both to the main form via Farmer Code.
The easier way would be to just use a Join query to bring in both 2011 and 2012 data into the query, and then filter the exact same way you're doing it now.
However, I agree with Hans Up that the data should really all be in one table and a FarmYear field should be added to differentiate.

Related

Crystal Reports Parameters - One List rather than pages

All,
My first ever post - here goes!
I am using a Dynamic Parameter to filter a report based on Purchase Order Number.
I have created the Parameter, but only so many results are on the list, then you have to change to page 2 and start looking through again, is there anyway to get all values on a single list.
I have am awaiting my IT Department to do the Registry edit to increase the search size, as I have well over 1,000 records.
Finally, I assume the user couldn't search for a relevant value in the list?
I am using Crystal Reports 2011 64 Bit Version
Any help would be great.

Can I set conditions for how values display?

I'm not sure if this is the best way to ask the question, but I can't think of a better one. I am new to Crystal Reports and have been basically left to figure it out on my own with just some resource books and YouTube.
My issue is this: I am building a report for a school that displays the next year's course selections. The report is pulling the values from an online form the students fill out and displays results on the report with two names, let's call them "report.name" and "report.value". "report.name" is an arbitrary value that the HTML of the form uses. I am wondering if it's possible to give Crystal a set of conditions so that I can format the way it displays to be a little cleaner.
Example:
CurrentMathClass Geometry
NextYearsMathClass Algebra 2
ElectiveChoice1-Grade10 Spanish 1
Right now the report is showing it like this because those are the values it is seeing. I would like it to be like this:
Current Math Class Geometry
Next Year's Math Class Algebra 2
Elective Choice 1 Spanish 1
Is there a way to give CR a set of conditions that tells it to print something different when it sees specific values, without removing the 'Name' field from the report?
Sorry if this questions is all over the place, I'm having a tough time organizing my thoughts. I appreciate any and all help.
Look to the right of Crystal. You'll see "Formula Fields".
Create a new formula. Call it #namechange or something.
If {report.name} = "CurrentMathClass" Then "Current Math Class".
Drag that formula object onto the report.

Dynamic Number Of Inputs In Form

This is supposed to be something very common in access: Say you have a table Employees with a many-to-many relationship with a table Workdays. As in, A day of work is a record in Workdays, and for any day of work there can be multiple employees who worked that day (Which is shown with a third table, I think it's called a junction table?).
Now, say you want to create a form that the user inputs the employees who worked on a certain day. There is a changing number of employees per day, therefore a changing number of text boxes/combo boxes to input the employees in.
I want to ask if there's a conventional/convenient/acceptable way to do this. I've thought of 2 ways: Having a certain maximum number of text boxes invisible, and every time one receives input set the visible property on a new one to Visible=True, and second way by using the CreateControl method. Both ways seem a little pointlessly complicated for something that should be very common.
You don't have to mess with dynamically creating or showing/hiding individual controls. All you probably need is a main form for the Workday with a Subform Control for the Employees who worked that day, something like this:
Design View:
Form View:
The subform control contains a Continuous Forms form that is bound to the junction table [TimeCards].
Workday EmployeeID HoursWorked
--------- ---------- -----------
9/10/2014 1 7
9/10/2014 3 6
9/10/2014 4 9
The "child" subform linked to the "master" form by the [Workday] value. You can enter a variable number of entries for a given Workday by simply adding new rows to the subform (via the "New Record" row with the asterisk beside it).
For more information, see
Create a form that contains a subform

Access Crosstab or Form based on 2 tables with dates

There are a few answers here already that have part answered my challenge in Access but not fully.
I have 2 tables that form the basis of my database: customers and items
I have a further 2 tables; one for order quantities against customers and items (orders_a), and one for forecast quantities against customers and items (forecast_a).
forecast_a and orders_a also have a date for each customer and item combination (basically there will be 12 dates only for the 12 months of the year - 01/01/12,01/02/12,01/03/12 etc.)
Because a user will want to manually forecast quantities for a full year for each customer and each item, if there were 2 customers and 2 items, the forecast_a table would contain 48 rows. 2 items x 2 customers = 4, 4 x 12 dates = 48. The same goes for the orders_a.
I know this is a slightly unusual set up but the user requires visibility of a full year.
My main challenge based on this is as follows:
A user will want to see a form with customers in the first column, items in the second and then (like a crosstab): Jan Forecast Qty, Jan Order Qty, Feb Forecast Qty, Feb Order Qty etc.
Therefore how would I create a crosstab to pull both these tables together, and how would I go about creating a form for data entry off the back of it?
I may well be constructing my database the wrong way but the fact that the user needs a 'grid' where every entry is manual means I can't just have a form that creates a record one at a time for orders or forecasts.
Thanks in advance!
Nick
The problem you have is that this is a task that is in essence a spreadsheet task. Accordingly it may be best handled in Excel. To achieve this create an Excel object, create a blank worksheet, populate it with the data, then have a button to suck it back into the database when the user has finished.

Database design challenge

I'm creating an virtual stamp card program for the iphone and have run into an issue with implementing my database. The program essentially has a main points system that can be utitlized through all merchants (sort've like air miles), but i also want to keep track of how many times you've been to EACH merchant
So far, i have created 3 main tables for users, merchants, and transactions.
1) Users table contains basic info like user_id and total points collected.
2) Merchants table contains info like merchant_id, location, total points given.
3) Transactions table simply creates a new row for every time someone checks into each merchant, and records date-stamp, user name, merchant name, and points awarded.
So the most basic way to deal with finding out how many times you've been to each merchant is to query the entire transaction table for both user and merchant, and this will give me a transaction history of how many times you've been to that specific merchant(which is perfect), but in the long run, i feel this will be horrible for performance.
The other straightforward, yet "dumb" method for implementing this, would be to create a column in the users table for EACH merchant, and keep the running totals there. This seems inappropriate, as I will be adding new merchants on a regular basis, and there would need to be new columns added to every user for every time this happens.
I've looked into one-to-many and many-to-many relationships for mySQL databases, but can't seem to come up with something very concrete, as i'm extremely new to web/PHP/mySQL development but i'm guessing this is what i'm looking for...
I've also thought of creating a special transaction table for each user, which will have a column for merchant and another for the # of times visited. Again, not sure if this is the most efficient implementation.
Can someone point me in the right direction?
You're doing the right thing in the sense of thinking up the different options, and weighing up the good and bad for each.
Personally, I'd go with a MerchantCounter table which joins on your Merchant table by id_merchant (for example) and which you keep up-to-date explicitly.
Over time it does not get slower (unlike an activity-search), and does not take up lots of space.
Edit: based on your comment, Janan, no I would use a single MerchantCounter table. So you've got your Merchant table:
id_merchant nm_merchant
12 Jim
15 Tom
17 Wilbur
You would add a single additional table, MerchantCounter (edited to show how to tally totals for individual users):
id_merchant id_user num_visits
12 101 3
12 102 8
15 101 6007
17 102 88
17 104 19
17 105 1
You can see how id_merchant links the table to the Merchant table, and id_user links to a further User table.