Create a another form to display only tracks from current album (h

S

skulmat

I am driving to make a database of my music library. So I have one from/table
with details of each album, and i want to make a form that when you click
"track info" (for example) it will bring up another form with all the tracks
for the current album. As of now I tried making a seperate tableand form to
do this and using relationships to link them, but I cant get it to only
display tracks from the current album. I must be missing something. any help
would be most appreciative.

thankx
 
T

Tom Wickerath

Hello Skulmat,
i want to make a form that when you click "track info"...
Is "track info" the caption of a command button? Assuming it is, you might
try code similar to the following, for a command button named
"cmdOpenTracksForm". This assumes that the name of the primary key is
"pkAlbumID", the name of the foreign key is "fkAlbumID", the name of the form
you want to open is "frmAlbumTracks", and the foreign key fkAlbumID is part
of the recordset for frmAlbumTracks:

Private Sub cmdOpenTracksForm_Click()
On Error GoTo ProcError

If Not IsNull([pkAlbumID]) Then
DoCmd.OpenForm "frmAlbumTracks", datamode:=acFormEdit, _
WhereCondition:="[fkAlbumID] = " & [pkAlbumID] & ""
End If


ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, _
"Error in OpenRecordForEditing event procedure..."
Resume ExitProc
End Sub

Note: The above WhereCondition statement is valid for a numeric primary key
/ foreign key relationship. If your key is text-based, then substitute the
following statement:

WhereCondition:="[fkAlbumID] = '" & [pkAlbumID] & "'"

This surrounds the primary key by a set of single quotes. And, if you are
using a text-based PK, you will have a bit more work in case the values can
include special characters, such as single or double quotes. Hopefully,
that's not the case.

Tom
_____________________________________________

:

I am driving to make a database of my music library. So I have one from/table
with details of each album, and i want to make a form that when you click
"track info" (for example) it will bring up another form with all the tracks
for the current album. As of now I tried making a seperate tableand form to
do this and using relationships to link them, but I cant get it to only
display tracks from the current album. I must be missing something. any help
would be most appreciative.

thankx
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top