R
Ryan Cabanas
Okay. I really need help because this is just killing me.
I have created a form from a table. Then I created another form from a
table and embedded it in to the first form (thus, a subform).
Now. I created a stored procedure and then created a report off of
that. The report prints all of my records nicely, but I cannot get it
to print just one record and the related sub elements. Let me try to
explain more clearly.
This is what I have, from a very generic viewpoint:
Table A (Main ID Numbers)
Table B (Items that belong to Main ID Numbers in Table A)
Table A
------------
1 - Tree
2 - Dog
3 - Cat
etc.
Table B
-----------
1 - Pine
2 - Elm
3 - Maple
4 - Dachsund
5 - Yorkshire Terrier
6 - Persian
7 - Tabby
Relationship of Tables
-------------------------------
1 - Tree
1 - Pine
2 - Elm
3 - Maple
2 - Dog
4 - Dachsund
5 - Yorkshire Terrier
3 - Cat
6 - Persian
7 - Tabby
Okay. So that's how my tables are layed out. Now the problem I'm
having is that on the main form, I have an ID for the items in Table A.
If I want to just print a report based on "1 - Tree", for instance, I
can't get it to do this automatically by pulling the ID from the
current record showing on the form.
This is what I've been trying to do in VBA from all the examples I've
been reading on here, but I can't get the dang thing to work and it's
driving me nuts. Here's the code from the builder (The above example
of "Nature" was just an example, for clarity's sake. My code below is
the real code):
1st Coding Try (Didn't Work)
-----------------------------------------
Dim stDocName As String
Dim strSQLStatement As String
strSQLStatement = "SELECT dbo.Version.VersionID,
dbo.Version.VersionDate, dbo.Version.ReleaseDate,
dbo.VersionItem.VersionItemDescription,
dbo.VersionFolder.FolderLocation , dbo.VersionType.VersionType,
dbo.CriticalStatus.CriticalDescription FROM dbo.Version INNER JOIN
dbo.VersionItem ON dbo.Version.VersionID = dbo.VersionItem.VersionID
INNER JOIN dbo.VersionFolder ON dbo.VersionItem.VersionFolderID =
dbo.VersionFolder.VersionFolderID INNER JOIN dbo.VersionType ON
dbo.VersionItem.VersionTypeID = dbo.VersionType.VersionTypeID INNER
JOIN dbo.CriticalStatus ON dbo.Version.CriticalID =
dbo.CriticalStatus.CriticalID WHERE (dbo.Version.VersionID =
'[Forms]![VersionForm]![txtVersionID]')"
stDocName = "rpt_VersionReport_SELECT"
DoCmd.OpenReport stDocName, acPreview, , strSQLStatement
2nd Coding Try (Didn't Work)
-----------------------------------------
Dim stDocName As String
Dim strVersionID As String
Dim strSQLStatement As String
strVersionID = Forms!VersionForm.txtVersionID
strSQLStatement = "dbo.Version.VersionID = " & strVersionID
stDocName = "rpt_VersionReport_SELECT"
DoCmd.OpenReport stDocName, acPreview, , strSQLStatement
-----------------------------------------
I'm sure I've tried a million other things, but none of them have
worked for me. I don't know what else to try. I want the report to
pick up the ID from the first form and use it as criteria to only print
that record (and its child records) in the report. I can't get it to
do this. It either prints nothing, or everything (with all the things
I've tried). I don't want to be prompted for the ID number, but I just
want it to be retrieved from the form when I click the button on the
form to print the report.
Thanks for the help!!!
Ryan
I have created a form from a table. Then I created another form from a
table and embedded it in to the first form (thus, a subform).
Now. I created a stored procedure and then created a report off of
that. The report prints all of my records nicely, but I cannot get it
to print just one record and the related sub elements. Let me try to
explain more clearly.
This is what I have, from a very generic viewpoint:
Table A (Main ID Numbers)
Table B (Items that belong to Main ID Numbers in Table A)
Table A
------------
1 - Tree
2 - Dog
3 - Cat
etc.
Table B
-----------
1 - Pine
2 - Elm
3 - Maple
4 - Dachsund
5 - Yorkshire Terrier
6 - Persian
7 - Tabby
Relationship of Tables
-------------------------------
1 - Tree
1 - Pine
2 - Elm
3 - Maple
2 - Dog
4 - Dachsund
5 - Yorkshire Terrier
3 - Cat
6 - Persian
7 - Tabby
Okay. So that's how my tables are layed out. Now the problem I'm
having is that on the main form, I have an ID for the items in Table A.
If I want to just print a report based on "1 - Tree", for instance, I
can't get it to do this automatically by pulling the ID from the
current record showing on the form.
This is what I've been trying to do in VBA from all the examples I've
been reading on here, but I can't get the dang thing to work and it's
driving me nuts. Here's the code from the builder (The above example
of "Nature" was just an example, for clarity's sake. My code below is
the real code):
1st Coding Try (Didn't Work)
-----------------------------------------
Dim stDocName As String
Dim strSQLStatement As String
strSQLStatement = "SELECT dbo.Version.VersionID,
dbo.Version.VersionDate, dbo.Version.ReleaseDate,
dbo.VersionItem.VersionItemDescription,
dbo.VersionFolder.FolderLocation , dbo.VersionType.VersionType,
dbo.CriticalStatus.CriticalDescription FROM dbo.Version INNER JOIN
dbo.VersionItem ON dbo.Version.VersionID = dbo.VersionItem.VersionID
INNER JOIN dbo.VersionFolder ON dbo.VersionItem.VersionFolderID =
dbo.VersionFolder.VersionFolderID INNER JOIN dbo.VersionType ON
dbo.VersionItem.VersionTypeID = dbo.VersionType.VersionTypeID INNER
JOIN dbo.CriticalStatus ON dbo.Version.CriticalID =
dbo.CriticalStatus.CriticalID WHERE (dbo.Version.VersionID =
'[Forms]![VersionForm]![txtVersionID]')"
stDocName = "rpt_VersionReport_SELECT"
DoCmd.OpenReport stDocName, acPreview, , strSQLStatement
2nd Coding Try (Didn't Work)
-----------------------------------------
Dim stDocName As String
Dim strVersionID As String
Dim strSQLStatement As String
strVersionID = Forms!VersionForm.txtVersionID
strSQLStatement = "dbo.Version.VersionID = " & strVersionID
stDocName = "rpt_VersionReport_SELECT"
DoCmd.OpenReport stDocName, acPreview, , strSQLStatement
-----------------------------------------
I'm sure I've tried a million other things, but none of them have
worked for me. I don't know what else to try. I want the report to
pick up the ID from the first form and use it as criteria to only print
that record (and its child records) in the report. I can't get it to
do this. It either prints nothing, or everything (with all the things
I've tried). I don't want to be prompted for the ID number, but I just
want it to be retrieved from the form when I click the button on the
form to print the report.
Thanks for the help!!!
Ryan