Results 1 to 8 of 8
  1. #1
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31

    Header

    Hello all!

    I am designing a database for hotel management and I would like to use a form to set a value that can be used on report headers and other forms in the database.

    An example of this is....

    If the hotel name is : Paradise Inn & Suites

    I want to create a form that a admin user can set the hotel name value as Paradise Inn & Suites and based on that setting I want a report to show the hotel name in the header of the report or another form in the database to show the hotel name in the report heading.



    I hope someone can help me do this because I am certain it is easy but im newer to in depth design.

  2. #2
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    The hotel name is part of the form recordset and the report recordset? Then the report header would have a textbox bound to the field that contains the hotel name.
    If not, you can pass the value to the report via the OpenArgs property of the report. Then in the report load event you can write code to make the value of the hotel name textbox equal to what you passed with OpenArgs.

    If that's not clear try posting more info that walks us through the steps that will be taken and more relevant details about the report. You could research OpenArgs to see if you think it will be useful for this.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    HotelierDream is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    31
    Quote Originally Posted by Micron View Post
    The hotel name is part of the form recordset and the report recordset? Then the report header would have a textbox bound to the field that contains the hotel name.
    If not, you can pass the value to the report via the OpenArgs property of the report. Then in the report load event you can write code to make the value of the hotel name textbox equal to what you passed with OpenArgs.

    If that's not clear try posting more info that walks us through the steps that will be taken and more relevant details about the report. You could research OpenArgs to see if you think it will be useful for this.
    What I would like to do is set a form that would be called Property Setup, this form would have text boxes that would set the property name and company name... In example:

    TextBox1 = Property Name such as "Paradise Inn & suites"
    TextBox2 = Company Name such as "PI LLC"

    Using the information provided I would like to set Global Variables that could be used to set the header of reports and other forms. Using this I would want a header on a report to show the value set in TextBox 1 and a line underneath that would display the value set in TextBox 2. Does that explain it better?

  4. #4
    Micron is offline Very Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    OK, so my suggestion would be to create your form and use comboboxes to provide your lists of properties and companies. You would give them row source properties but not control source (i.e. they would not be bound). If one of the lists depends on the other, you can make them 'cascading' combos (you can research that). A button on the form can be used to open the report. However, code for that would be specific to one report. If you want the ability to open other reports based on those list selections you need a way to provide that (possibly a table of report names and another combo to provide a reports list). Once you know the combo names you can build a query that references them as criteria for the companies and properties and then create a report based on that query. The needed values will then be shown in the textboxes you've put onto the report. Downside is that you'll raise an error if you open the report without the form being open (unless you open in design view), or possibly an error if one or both combo values are not entered. Button click code can prevent the latter.

    If you really need the global variables instead I'd still use the combos on a form. The AfterUpdate event on each could set the value to be the one chosen. Something like

    Sub comboNameHere_AfterUpdate()
    GlobalVariableName = Me.comboNameHere
    End Sub

    Be aware that global values can be lost if errors are raised (not warnings) although it's been my experience that mostly happens during development.
    HTH.
    Last edited by Micron; 12-24-2020 at 08:53 AM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,757
    Hi

    I think you are overthinking this.

    I agree with Micron when he says:- "The hotel name is part of the form recordset and the report recordset? Then the report header would have a textbox bound to the field that contains the hotel name."

    If you go with your suggestion of 2 Textbox's you will always have to type in the specific Hotel/Company names required.
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,235
    I would suggest you create a "settings" table with those two fields and any others you might want (such as the location of a logo file that you could embedd in the report's header), and a small data entry "Settings form to populate the table. In the report you would then simply use dlookups to populate the required text boxes.

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,705
    Quote Originally Posted by Gicu View Post
    I would suggest you create a "settings" table with those two fields and any others you might want (such as the location of a logo file that you could embedd in the report's header), and a small data entry "Settings form to populate the table. In the report you would then simply use dlookups to populate the required text boxes.

    Cheers,
    Vlad
    Exactly. And this approach could accommodate the DB supporting multiple companies.
    Vlad gets a star.

  8. #8
    Hipromark is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2020
    Location
    Bogota, Colombia
    Posts
    15
    Quote Originally Posted by HotelierDream View Post
    Hello all!

    I am designing a database for hotel management and I would like to use a form to set a value that can be used on report headers and other forms in the database.

    An example of this is....

    If the hotel name is : Paradise Inn & Suites

    I want to create a form that a admin user can set the hotel name value as Paradise Inn & Suites and based on that setting I want a report to show the hotel name in the header of the report or another form in the database to show the hotel name in the report heading.

    I hope someone can help me do this because I am certain it is easy but im newer to in depth design.
    If I understood well, it is really easy to do, don't go too creative, forget about complicated procedures. Just add a column(or field, if you prefer to call it like that) to the table in which you have the hotel id. Or another option is to create a table that will store all the different headings and then select the proper heading at the moment you open the report or form. You can link that by ID or also use combo boxes.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 12-01-2017, 12:52 PM
  2. Replies: 2
    Last Post: 01-12-2017, 02:30 AM
  3. Replies: 1
    Last Post: 06-15-2016, 08:45 AM
  4. Replies: 13
    Last Post: 06-13-2014, 03:25 PM
  5. Replies: 1
    Last Post: 04-06-2014, 10:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums