A followup to this, in case it might help anyone else:
I checked out Crystal Long's site (along with many many many others)
and Arvin Meyer's advice, and I ended up using a continuous subform
with just a combo box on it to populate the joining table. Obvious I
know! I turned off record selectors, nav buttons, and scrollbars to
help it "sink in" to the main form visually, and wrote code to keep it
sized correctly and move other elements around in relation to it. The
code I used to size it is below:
'mainFrm - Me if on main form. Me.Parent if on subform.
'mainName - Name of main form in "quotes".
'subName - Name of sub form in "quotes".
'subWidth - Width of sub form.
Public Sub SubResize(mainFrm As Form, mainName As String, subName As
String, subWidth As Long)
If DCount(mainName & "ID", "t_" & mainName & subName, mainName & "ID =
Forms.f_" & mainName & "Edit." & mainName & "ID") > 2 Then 'Does
subform contain more than 2 records?
mainFrm("sub_" & mainName & subName).Height = 945 'Set height to 3
lines
mainFrm("sub_" & mainName & subName).Form.ScrollBars = 2 'Vertical
scrollbar on
mainFrm("sub_" & mainName & subName).Width = subWidth + 300 'Increase
subform width to accomodate scrollbar
Else
mainFrm("sub_" & mainName & subName).Height = (DCount(mainName & "ID",
"t_" & mainName & subName, mainName & "ID = Forms.f_" & mainName &
"Edit." & mainName & "ID") + 1) * 315 'Set height to appropriate
number of records
mainFrm("sub_" & mainName & subName).Form.ScrollBars = 0 'Scrollbars
off
mainFrm("sub_" & mainName & subName).Form.Width = subWidth 'Set
subform width without scrollbars
End If
End Sub
I'm working a good generic solution for relocating elements, but I
haven't come up with it yet. I'm currently using something like the
following wherever necessary:
Public Sub SessionRelocate(frm As Form)
frm.sub_SessionStaff.Top = frm.sub_SessionDate.Top +
frm.sub_SessionDate.Height + 120
frm.sub_SessionInstructor.Top = frm.sub_SessionStaff.Top +
frm.sub_SessionStaff.Height + 120
frm.sub_SessionLearner.Top = frm.sub_SessionInstructor.Top +
frm.sub_SessionInstructor.Height + 120
frm.sub_SessionSP.Top = frm.sub_SessionLearner.Top +
frm.sub_SessionLearner.Height + 120
frm.Comments.Top = frm.sub_SessionSP.Top + frm.sub_SessionSP.Height +
120
frm.sub_SessionStaffLabel.Top = frm.sub_SessionStaff.Top
frm.sub_SessionInstructorLabel.Top = frm.sub_SessionInstructor.Top
frm.sub_SessionLearnerLabel.Top = frm.sub_SessionLearner.Top
frm.sub_SessionSPLabel.Top = frm.sub_SessionSP.Top
frm.CommentsLabel.Top = frm.Comments.Top
End Sub
To make that into a generic function, I'm working on a solution for
figuring out which control (if any) is next on the form, so that I
don't have to know each control ahead of time. I figure I can then
put it into a loop with argument substitutions like the resizing
function.
Thanks for all your help, I'm learning a lot!
Eric Braden
Yes, you would have 3 records as you show in your example.
A subform is usually used to add records in the many-side table. In your
case it appears that would be based on tblCaseMod.
You will get significant benefit out of Crystal Long's Video and PDF
tutorials at:
http://www.accessmvp.com/Strive4Peace/Index.htm
--
Arvin Meyer, MCP, MVPhttp://
www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com
I think I may be misunderstanding (or I just didn't explain
correctly). I *think* I'm doing the right thing. In attempting to
avoid multiple values in one field, I created the tblCaseMod table.
My idea is that it would store a linkage that in practical terms
basically said "Case #32 uses Modalities 3, 4 and 5", but would take 3
records to do it.
A corresponding example set of records in tblCaseMod would have the
following values:
CaseModID - 3 (automatically generated PK)
CaseID - 32 (FK from tblCases)
ModID - 3 (FK from tlbModality)
CaseModID - 4
CaseID - 32
ModID - 4
CaseModID - 5
CaseID - 32
ModID - 5
*If* that is correct methodology, I'm having issues coming up with a
way to get the input out of a "New Case" or "Edit Existing Case" form
into the joined table.
I'm trying very hard to think in terms of normalization, but I know
the concept slips by me pretty often. I was under the impression that
using a joining table like this was in the spirit of normalization,
instead of having something like a bunch of Yes/No fields in my
tblCases table for each modality (leading to a situation in which I
would have to do a bunch of work to add or change a modality).
If these questions are too elementary, let me know. I'd like to sit
down and take a course or read for several hours about normalization
theory, but since I'm learning as I'm creating this for work, I don't
really have that option and just take in snippets at a time. This is
a brute-force, on-the-job, self-taught process. I truly enjoy it, but
some days it can be mighty frustrating.
Eric B.
So now you are violating a database normalization rule, that's actuallya
fairly serious violation. That being do not store multiple values in a
single field for 1 record. You should use a combo box instead and have
multiple rows of data, instead of a single row with multiple values in 1
field.
When designing and using databases, think long rather than wide. More
rows,
less fields. More rows, 1 field.
messageI've been searching most of the morning, and I have yet to find an
answer this, so pardon me for asking yet another question.
The discussion below led me to eliminate lookup fields in my tables.
I now have an additional table set up to link them. I now have a
listbox on my form with it's row source set as a query which pulls
from tblModality (SELECT [tblModality].[ModID], [tblModality].
[Modality] FROM tblModality; ). I have the Multi Select property set
to Simple so the user can select more than one modality for each
case.
I am having trouble figuring out how to transfer the selections from
the listbox into my new linking table (tblCaseMod). The selections
would go in the ModID field, and hopefully I can figure out how to get
it to just set the CaseID field to whatever the current case is on the
form. Is it possible to do it without VBA? If it's only possible
through VBA, I guess now is as good a time as any to start learning!
Am I just wrong-headed and going about it in the wrong way?
tblCases
CaseID (PK)
CaseName
DateCreated
-many other descriptive fields-
tblModality
ModID (PK)
ModType
tblCaseMod
CaseModID (PK)
CaseID (FK)
ModID (FK)
...
read more »- Hide quoted text -
- Show quoted text -