Answered by:
Title

Question
-
i have multiple forms and reports in my database, like any other database, and I would like that the same Project Number or Project Description appears on top of every page once the database is reset of the new Project.
i don't want to copy paste the same information everywhere. Just want to put it somewhere in the database and it should come from there on top of every form or report, as soon as new project information is setup.
I've tried to put Project # and Project Description a table, but it doesn't work when i put it on the form because form looks for the relationship information in this case and this information is completely separate from any other table.
Any ideas please??
Monday, October 12, 2015 8:17 AM
Answers
-
i have multiple forms and reports in my database, like any other database, and I would like that the same Project Number or Project Description appears on top of every page once the database is reset of the new Project.
i don't want to copy paste the same information everywhere. Just want to put it somewhere in the database and it should come from there on top of every form or report, as soon as new project information is setup.
I've tried to put Project # and Project Description a table, but it doesn't work when i put it on the form because form looks for the relationship information in this case and this information is completely separate from any other table.
Any ideas please??
There are several ways you might go about this. The simplest might be to use the DLookup() function to look up the Project Number and/or Project Description. If you want it to display in the form's caption bar, though, you will have to use code to set the forms .Caption property. You could do that in the form's Open event. You could make that easier by having a common function (named, for example, "CaptionInfo"), stored in a standard module, that receives a reference to a form or report and sets the .Caption property of that object to the looked-up text you want to display. Then you could set the OnOpen property of every form to "=CaptionInfo([Form])", and every report to "=CaptionInfo([Report])".
On the other hand, if you don't need this info to appear in the caption bar, you don't need to write any code at all. You can just put a text box on the form or report and set its .ControlSource property to a DLookup expression that returns the project information; for example,
=DLookup("[ProjectNumber] & ' - ' & [ProjectDescription]", "tblCurrentProject")
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html- Marked as answer by KhurramKZ Tuesday, October 13, 2015 2:47 AM
Monday, October 12, 2015 2:39 PM
All replies
-
i have multiple forms and reports in my database, like any other database, and I would like that the same Project Number or Project Description appears on top of every page once the database is reset of the new Project.
i don't want to copy paste the same information everywhere. Just want to put it somewhere in the database and it should come from there on top of every form or report, as soon as new project information is setup.
I've tried to put Project # and Project Description a table, but it doesn't work when i put it on the form because form looks for the relationship information in this case and this information is completely separate from any other table.
Any ideas please??
There are several ways you might go about this. The simplest might be to use the DLookup() function to look up the Project Number and/or Project Description. If you want it to display in the form's caption bar, though, you will have to use code to set the forms .Caption property. You could do that in the form's Open event. You could make that easier by having a common function (named, for example, "CaptionInfo"), stored in a standard module, that receives a reference to a form or report and sets the .Caption property of that object to the looked-up text you want to display. Then you could set the OnOpen property of every form to "=CaptionInfo([Form])", and every report to "=CaptionInfo([Report])".
On the other hand, if you don't need this info to appear in the caption bar, you don't need to write any code at all. You can just put a text box on the form or report and set its .ControlSource property to a DLookup expression that returns the project information; for example,
=DLookup("[ProjectNumber] & ' - ' & [ProjectDescription]", "tblCurrentProject")
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html- Marked as answer by KhurramKZ Tuesday, October 13, 2015 2:47 AM
Monday, October 12, 2015 2:39 PM -
Thank youTuesday, October 13, 2015 2:48 AM