473,405 Members | 2,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Junction in a Form

I have 3 tables

Table 1: tblMovie
MovID (PK)
MovName

Table 2: tblGenre (manually inputted; limited to existing data)
GenreID (PK)
GenreName

Table 3: junction (MovID has lookup on MovName from tblMovie; GenreID has a lookup on GenreName from tblGenre)
MovID
GenreID


I would like to have a form which shows the movie title and its genre;
e.g
Title: Fictional Movie
Genre: Action, Horror, Suspense, Drama

I've tried using text box, combo box, and list box. But at most i was only able to show a Single Genre Name with mutiple record instance of the same title.

Any help on how to solve this problem is greatly appreciated

tnx.
Jun 3 '07 #1
5 1643
ADezii
8,834 Expert 8TB
I have 3 tables

Table 1: tblMovie
MovID (PK)
MovName

Table 2: tblGenre (manually inputted; limited to existing data)
GenreID (PK)
GenreName

Table 3: junction (MovID has lookup on MovName from tblMovie; GenreID has a lookup on GenreName from tblGenre)
MovID
GenreID


I would like to have a form which shows the movie title and its genre;
e.g
Title: Fictional Movie
Genre: Action, Horror, Suspense, Drama

I've tried using text box, combo box, and list box. But at most i was only able to show a Single Genre Name with mutiple record instance of the same title.

Any help on how to solve this problem is greatly appreciated

tnx.
If you defined your Relationships as follows, you wouldn't need any type of Lookup:
Expand|Select|Wrap|Line Numbers
  1. [tblMovie].[MovID](1) ==> [Junction].[MovID](MANY)
  2. [tblGenre].[GenreID](1) ==> [Junction].[GenreID](MABY)
You could then just simply create a Form/Sub-Form scenario with the Composite Key from the Junction Table as the Link.
Jun 3 '07 #2
If you defined your Relationships as follows, you wouldn't need any type of Lookup:
Expand|Select|Wrap|Line Numbers
  1. [tblMovie].[MovID](1) ==> [Junction].[MovID](MANY)
  2. [tblGenre].[GenreID](1) ==> [Junction].[GenreID](MABY)
You could then just simply create a Form/Sub-Form scenario with the Composite Key from the Junction Table as the Link.
Thanks for the Info. Actually the sole purpose of the lookup was so that Genre and Title wouldnt show up as only numbers.

Anyways tried it as you said. but still not working. To be more elaborate. my problem is that my records on form shows up like this;

Record 1:
Title: Fictional Movie 1
Genre: Action
Record 2:
Title: Fictional Movie 1
Genre: Comedy
Record 3:
Title: Fictional Movie 2
Genre: Romance
Total of 3 records

Instead of like this:
Record 1:
Title:Fictonal Movie 1
Genre: Action, Comedy
Record 2:
Title: Fictional Movie 2
Genre: Romace

Total of 2 records

I'd like to have the Genre in a single textbox if possible, but a listbox is acceptable too. Thinking of making a loop which looks up the junction table, but have no idea no how to do it. Can anyone give a hint on how to start.

Sorry for the long post.
Jun 3 '07 #3
ADezii
8,834 Expert 8TB
Thanks for the Info. Actually the sole purpose of the lookup was so that Genre and Title wouldnt show up as only numbers.

Anyways tried it as you said. but still not working. To be more elaborate. my problem is that my records on form shows up like this;

Record 1:
Title: Fictional Movie 1
Genre: Action
Record 2:
Title: Fictional Movie 1
Genre: Comedy
Record 3:
Title: Fictional Movie 2
Genre: Romance
Total of 3 records

Instead of like this:
Record 1:
Title:Fictonal Movie 1
Genre: Action, Comedy
Record 2:
Title: Fictional Movie 2
Genre: Romace

Total of 2 records

I'd like to have the Genre in a single textbox if possible, but a listbox is acceptable too. Thinking of making a loop which looks up the junction table, but have no idea no how to do it. Can anyone give a hint on how to start.

Sorry for the long post.
  1. Create a Form based solely on tblMovie consisting of the [MovID] and [MovName] Fields.
  2. Create a Query named qryMovieGenreJunction consisting of all 3 Tables joined as previously indicated.
  3. Assuming that a Text Box (Unbound) on frmMovies is called txtGenre, the followinig code in the Current() Event of the Form will produce the desired results.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Current()
    2. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
    3. Dim MySQL As String, strGenre As String
    4.  
    5. MySQL = "Select * From qryMovieGenreJunction Where [MovID]=" & Me![MovID]
    6.  
    7. Set MyDB = CurrentDb()
    8. Set MyRS = MyDB.OpenRecordset(MySQL, dbOpenDynaset)
    9.  
    10. Do Until MyRS.EOF
    11.   strGenre = strGenre & MyRS![GenreName] & ","
    12.   MyRS.MoveNext
    13. Loop
    14.  
    15. strGenre = Left$(strGenre, Len(strGenre) - 1)
    16.  
    17. Me![txtGenre] = strGenre
    18.  
    19. MyRS.Close
    20. End Sub
Sample OUTPUT for txtGenre Field:
Expand|Select|Wrap|Line Numbers
  1. Action,Comedy,Romance
  2. Unknown,Weird
Jun 3 '07 #4
  1. Create a Form based solely on tblMovie consisting of the [MovID] and [MovName] Fields.
  2. Create a Query named qryMovieGenreJunction consisting of all 3 Tables joined as previously indicated.
  3. Assuming that a Text Box (Unbound) on frmMovies is called txtGenre, the followinig code in the Current() Event of the Form will produce the desired results.
    Expand|Select|Wrap|Line Numbers
    1. Private Sub Form_Current()
    2. Dim MyDB As DAO.Database, MyRS As DAO.Recordset
    3. Dim MySQL As String, strGenre As String
    4.  
    5. MySQL = "Select * From qryMovieGenreJunction Where [MovID]=" & Me![MovID]
    6.  
    7. Set MyDB = CurrentDb()
    8. Set MyRS = MyDB.OpenRecordset(MySQL, dbOpenDynaset)
    9.  
    10. Do Until MyRS.EOF
    11.   strGenre = strGenre & MyRS![GenreName] & ","
    12.   MyRS.MoveNext
    13. Loop
    14.  
    15. strGenre = Left$(strGenre, Len(strGenre) - 1)
    16.  
    17. Me![txtGenre] = strGenre
    18.  
    19. MyRS.Close
    20. End Sub
Sample OUTPUT for txtGenre Field:
Expand|Select|Wrap|Line Numbers
  1. Action,Comedy,Romance
  2. Unknown,Weird

I'm getting a lot of errors... might just be my setting though. Gonna check it first. btw can I know what references you had checked when you did this code. I seem to get "cannot find project or library" on the dbopendynaset line even though i have DAO 3.6
Jun 4 '07 #5
ADezii
8,834 Expert 8TB
I'm getting a lot of errors... might just be my setting though. Gonna check it first. btw can I know what references you had checked when you did this code. I seem to get "cannot find project or library" on the dbopendynaset line even though i have DAO 3.6
In your specifric caes, you'll need a Reference set to the Microsof DAO 3.6 Object library.
Jun 4 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mksql | last post by:
As an example, I am building an authentication mechanisim that will use data in the 3 left tables to determine rights to objects in a destination table, diagrammed below. In this structure,...
8
by: Marcy | last post by:
I am trying to build a database to keep track of training topics completed by people in my department. Our department has a set of 37 training topics. There are 7 job classifications in the...
1
by: LurfysMa | last post by:
I am working on an electronic flashcard program. Most of the subjects are simple lists of questions and answers. Those seem to be working. Some of the "subjects" have "categories" of questions. ...
3
by: inthemix | last post by:
My goal is to have a sub-form located on the main form which containts a listbox. The user will be able to select anany number of offices (by officeName) from this listbox. IMO the design is very...
1
by: que576 | last post by:
I have created a junction table so that I can relate data from 2 other tables. Table 1 - Category Table (has the following fields with data) CatID (primary key) CategoryName CategoryStatus ...
5
by: jatrojoomla | last post by:
Hi! Is there any one with knowledge of CJ API development I am getting error like: http://fb.aafter.com/cj/testb/support.php during Commission Junction SOAP access Commission Junction:...
2
by: Henry Stockbridge | last post by:
Hi, I need a recommendation when to add a record to a junction table that complements a many to many relationship. There will be a Contacts form, and an Interests subform with the parent/child...
3
by: dbertanjoli | last post by:
Hello, I have a questinarrie webform I use INSERT statement(s) to insert a new record in the User and Questions tables and then (HERE IS MY PROBLEM) I need to update my junction table...
1
by: pwebbie | last post by:
In an MS Access Project tied to SQL Server, I am trying to create a data entry form that allows the user to enter info about a law, and then (in a datasheet) edit/insert related web site records...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
Oralloy
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,...
0
jinu1996
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.