Okay here goes,
I have 3 tables
[Person Table]
Person_ID: text;
first_name: text;
last_name: text;
[Group_Definition Table]
Group_ID; Autonumber;
Group_Desc: Text;
[Person_Group_Membership]
person_id: text;
Group_ID; number;
Sample Data
[Person Table]
aaaa Jim Johnson
bbbb Joe Jones
cccc John Doe
[Group_Definition Table]
1 GroupA
2 GroupB
3 GroupC
[Person_Group_Membership]
aaaa 1
bbbb 1
aaaa 2
cccc 3
Now, I would like to have a form, where it lists the persons name, and a group of check boxes, one checkbox for each group. as you scroll through the people, there is a check in the box if the person has an entry in that group; also, if a check is placed in the box, a corresponding entry is made in the person_Group_membership table.
I am just not sure of the proper way to go about doing this. Thanks!
11 2454 NeoPa 32,556
Expert Mod 16PB
Nicely worded question :)
Unfortunately I think this is a CrossTab query question (not an area I'm very good in).
I think though, that a crosstab query of the groups per user would be required. It would not be updateable though, so would require code in the AfterUpdate events of the CheckBoxes to add and delete records as and when checked. Such code would always need to be succeeded with a call of Me.Requery. Does this make sense?
PS. You may get some other, better ideas from the other Experts.
Hi, gixxer.
It will require some unusual design of the form. - the simplest way to represent person's membership is to use subform (datasheet or continuous forms view), lets say main form based on [Person Table] is [frmPeople], subform is [frmMembership]
- as soon as you want to see all groups with checkboxes indicating membership the recordsource for form object of this subform should be outer join of [Group_Definition Table] and [Person_Group_Membership], like the following
-
SELECT [Group_Definition Table].Group_Desc, IIf(IsNull(t.Person_ID),False,True) AS blnBelongsTo, [Group_Definition Table].Group_ID
-
FROM [Group_Definition Table] LEFT JOIN (SELECT [Person_Group_Membership].* FROM [Person_Group_Membership] WHERE [Person_Group_Membership].Person_ID=Forms!frmPeople!Person_ID) AS t ON [Group_Definition Table].Group_ID = t.Group_ID;
-
note: controlsource for future checkbox is calculated field [blnBelongsTo], [Person_Group_Membership] is filtered by Forms!frmPeople!Person_ID prior to join because native Access form/subform link via master/child fields will not work - you need to bind the query fields to [frmMembership] controls ([Group_ID] control should be invisible)
- [frmMembership] properties: allow additions/deletions/edit/filters should be set to "no"
- the action check/uncheck person's membership in group actually means append/delete record to/from [Person_Group_Membership]
- you may handle [blnBelongsTo] checkbox MouseDown event to run appropriate append/delete queries. Something like this:
-
Private Sub blnBelongsTo_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
-
'Exit sub if parent form on *New record* or other than Leftbutton was pressed
-
If IsNull(Me.Parent!keyPersonID) Or Button <> 1 Then Exit Sub
-
-
With DoCmd
-
.SetWarnings False
-
Select Case Me.blnBelongsTo
-
Case True
-
.RunSQL "DELETE * FROM [Person_Group_Membership] WHERE Person_ID='" _
-
& Me.Parent!keyPerson_ID & "' AND Group_ID=" & _
-
Me.Group_ID & ";"
-
Case False
-
.RunSQL "INSERT INTO [Person_Group_Membership] (Person_ID, Group_ID)" & _
-
" VALUES ('" & Me.Parent!Person_ID & ", " & _
-
Me.Group_ID & ");"
-
End Select
-
.SetWarnings True
-
Me.Requery
-
End With
-
-
End Sub
-
Any chance the response could be re-posted?
Some of the text in the first code example has been truncated to be nothing more than the letter "T" making it a bit difficult to follow...
big thanks if you can,
mark
Which post are you referring to? I don't see anything cut off. Did you scroll to the right in the code box?
in the first block of code: -
SELECT [Group_Definition Table].Group_Desc, IIf(IsNull(t.Person_ID),False,True) AS blnBelongsTo, [Group_Definition Table].Group_ID
-
FROM [Group_Definition Table] LEFT JOIN (SELECT [Person_Group_Membership].* FROM [Person_Group_Membership] WHERE [Person_Group_Membership].Person_ID=Forms!frmPeople!Person_ID) AS t ON [Group_Definition Table].Group_ID = t.Group_ID;
you'll note that a few time there is a letter "t", which refers to something...
You mean the "t." ? That's not cut off. It's referring to an alias given to the table.
NeoPa 32,556
Expert Mod 16PB
As Rabbit says that is an ALIAS defined in the SQL. It may help to see it all laid out in a more readable format : -
SELECT [Group_Definition Table].Group_Desc
-
, IIf(IsNull(t.Person_ID),False,True) AS blnBelongsTo
-
, [Group_Definition Table].Group_ID
-
FROM [Group_Definition Table]
-
LEFT JOIN
-
(SELECT [Person_Group_Membership].*
-
FROM [Person_Group_Membership]
-
WHERE [Person_Group_Membership].Person_ID=Forms!frmPeople!Person_ID) AS t
-
ON [Group_Definition Table].Group_ID = t.Group_ID;
Always bear in mind, if you can't read it well on the page then you can always copy and paste it into something more controllable (EG. Notepad.) and read it there ;-)
I sincerly appreciate your reply, and at the same time apologize...
"alias" is something that as a self-taught blah, blah..., I'm aware of, but haven't yet given myself much experience with.
never-the-less,
I'm combing thru the code and the text of the page, and I can't seem to locate where the alias has been assigned.
I would think that it is in the first line of code: - SELECT [Group_Definition Table].Group_Desc,
-
IIf(IsNull(t.Person_ID),False,True) AS blnBelongsTo, [Group_Definition Table].Group_ID
-
where t would then refer to the [Group_Definition Table], but the code then goes on to reference the field (t.Person_ID) which is not part of that table.
For the moment (rather then getting side tracked in learning about "alias"), would you tell me which table 't' refers to (I presume either: [Person Table] or [Person_Group_Membership] )
With thanks in advance,
Mark
NeoPa's reformatted code block, line number 8, at the very end
NeoPa 32,556
Expert Mod 16PB
For anyone else struggling with that, the subquery (in parentheses - See Subqueries in SQL) is ALIAS ed in order to refer to it directly. ALIAS simply means to assign a new name to a construct. This can be for tables, fields, queries, subqueries defined within parentheses, etc.
In SQL this is done using the ALIAS keyword, which can be abbrviated to AS as well as left out completely. Here are some illustrative examples : - SELECT [tblEmployee].[Employee ID] ALIAS [EmpID]
-
, [tblEmployee].[Employee Name] AS [EmpName]
-
FROM [Employee Table] [tblEmployee]
This illustrates each possibility. I've underlined the ALIAS in each case.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Emanuel Marciniak |
last post by:
Hi all,
We have the form which uses checkboxes for several fields and the target
action points to outside webservice. Unfortunatelly they do not support
checkboxes. How to pass it as a radio...
|
by: Frances |
last post by:
Hi All,
* PREMISE *
I'm creating an Access form with 150 items subdivided into 20
categories. Multiple categories (and items) can be selected so my
user wants checkboxes. All of the options...
|
by: Johnfcf |
last post by:
I have a database consisting of 3 tables, the main table with main
contact info, a second table with additional address info and a third
table consisting of additional contact information, or more...
|
by: filbennett |
last post by:
Hi Everyone,
I'm generally unfamiliar with Access form design, but have programmed
Cold Fusion applications for a couple of years.
I'd like to build a data entry form in Access that allows the...
|
by: ricky.agrawal |
last post by:
I'm really not sure how to go about this in Access. What I've created
is a table for each location. Those tables are identical in format but
different in information.
The tables are named after...
|
by: mforema |
last post by:
Hi everybody,
I need help with a search form. I'm trying to search a table based on "Keywords" and "MajorCategories"; both criteria have their own fields in the table.
The form has a "keyword"...
|
by: Salad |
last post by:
Using A97, SP2, most current jet35.
I have a search form. The op enters an id to search/find. If found, a
data entry form is presented for that id. This form has 7 or 8 combos,
a bunch of...
|
by: ebo2006 |
last post by:
In the form there 16 checkboxes for types of errors a user can choose from depending on the number of errors found in one account entry. I believe putting 16 corresponding checkbox fields in the...
|
by: goldybobble |
last post by:
Hello,
I had an Access database that would classify items with one classification, and then classify one sub-classification based on the selection for the main classification.
This worked well,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |