If anyone has any Ideas where I am going wrong with this I would really
appreciate your input.
You're having severe problems because your tables aren't normalized. I'd
suggest changing the structure of the two tables and adding a new one, so
that they look like the following.
tblFacility:
FID, AutoNumber, primary key
FacilityName, Text
tblFacilityRates:
FRID, AutoNumber, primary key
FID, Long, foreign key to tblFacility table
Licensure, Text
Rate, Currency
Shift, Text (?) (Perhaps this should be Long if it's always numerical.)
tblRequest:
RID, AutoNumber, primary key
FRID, Long, foreign key to tblFacilityRates table
TherapistName, Text
RequestFilled, Boolean
et cetera
The data would look like:
tblFacility:
FID FacilityName
1 Mercy Hospital
2 MLK Hospital
tblFacilityRates:
FRID FID Licensure Rate Shift
1 1 RN blah 1
2 1 RN blah 2
3 1 RN blah 3
4 1 LVN blah 1
5 1 LVN blah 2
6 1 LVN blah 3
7 2 RN blah 1
8 2 RN blah 2
et cetera
tblRequest:
RID FRID TherapistName RequestFilled
1 1 Hugh Dunnit X
2 4 Justin Case X
3 3 Bill M. Later X
4 7
et cetera
Create a new query and paste the following into the SQL View pane:
SELECT RID, tblRequest.FRID, tblFacilityRates.FID,
Licensure, Shift, Rate, TherapistName, RequestFilled
FROM (tblFacility INNER JOIN tblFacilityRates
ON tblFacility.FID = tblFacilityRates.FID)
INNER JOIN tblRequest ON
tblFacilityRates.FRID = tblRequest.FRID;
Add the other fields in the tblRequest table to this query. Save the query
as qryFacilityRequestRates and run it. The proper rate is automatically
assigned to the existing records, according to which facility, license
required, and shift.
For data input, use a form that uses this autolookup query to automatically
fill in the fields for you. To do so, follow these instructions:
Create a new query. Paste the following SQL into the SQL View pane:
SELECT FRID, FacilityName, Licensure, Rate, Shift
FROM tblFacility INNER JOIN tblFacilityRates
ON tblFacility.FID = tblFacilityRates.FID
ORDER BY FacilityName, Shift, Licensure;
Save it and name it qryFacilityRates.
Create a new form. Make sure that the form is bound to the
qryFacilityRequestRates query and all fields in the query are placed on the
form.
Open your new form in design view and change the text box for FRID into a
combo box. To do this, select the FRID text box and right click for the
pop-up menu and select "Change to" then select "Combo Box." Open the
Properties dialog window for this new combo box. On the "Format" tab, change
the "Column Count" Property from 1 to 5 and change the "Column Widths" to
0";1";0.3";0";0.2"
On the "Data" tab, change the "Row Source" Property to qryFacilityRates.
Save the new form.
To show the autolookup query in action, open the new form in "Form View."
Add a new record and select the item with the correct facility name,
licensure, and shift in the "FRID" combo box. The rate and the rest of the
fields has been filled in automagixly for the other text boxes in the form.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
Confused said:
This is the problem that I am running into. I have different facilities that
I send staff to, and each of these facilities have different pay rates per
shift per licensure. What I need is a calculation that grabs the right
licensure with the right shift and displays the right amount of pay.
What I am currently using is:
ex. RNRate1A: IIF([tblRequest].[Licensure]= "RN", IIF([Shift]="1",
[RNRate1],0))
ex. RNRate2A: IIF([tblRequest].[Licensure]= "RN", IIF([Shift]="2",
[RNRate2],0))
The two tables I am using for this query are:
tblFacility:
FacilityName,RNRate1, RNRate2, RNRate3, LPNRate1, LPNRate2, LPNRate3 etc
tblRequest:
FacilityName, Licensure, Shift, TherapistName, RequestFilled, etc.
If anyone has any Ideas where I am going wrong with this I would really
appreciate your input. Thank you in advance!