Defining Variables

My bad, I thought those were tabs but I see the tabs now. Hmm, then I am still missing something...

1. I have a main menu form that you can select a number of buildings (eg.1-100).
So you have now selected your Building ID

2. I then click and open a form called bldgform for that building that a have a textbox with name and control source of BldgAbb_ID for bldg1.
Then you open bldgform, I am assuming from the Main Menu, which will show the name of the building.

3. I then click on a button cmdElev on bldgform that opens a report to show all the elevators that match (BldgAbb_ID) bldg1 and have information on it.
From the bldgform I can open the reports which are absed on the Building ID

4. On the same bldgform I have another button cmdAlarms that opens another report that same way with control source and name BldgAbb_ID.
And I can also open additional reports.

Now, the associated image which can be stored in table for the buildings can be loaded via code.

Why do you need so many Forms when it appears everything can be done from the Main Menu and blsgform? Why do you need a Module to declare variables when the Building ID is already available? Just flip the image.
 
Why do you need so many Forms when it appears everything can be done from the Main Menu and blsgform? Why do you need a Module to declare variables when the Building ID is already available? Just flip the image.

Because transparent buttons go over images of pumps (etc.) you click on the pump it opens a form with info on it. Each transparent button goes to a specific record for a piece of equip in this common form for each building.

example to make it clearer
I try to make it simple......
Imagine a picture of a building with windows in a form...
Each window of the building has a transparent command button....
If you click on the window it brings up another form with who works in the office...
But you have many buildings each building completely shaped different.....
Some with hardly any windows and different people working in the offices....
So the command buttons could not be copied over as each building is completely different....


Thanks for your time
 
Ah, I'm now seeing the *bigger* picture. So in creating a Module you are hoping to use one line to call the code for the buttons? Because no matter what each button is going to need something. Nope, let me restate that... you could just use an Embedded Macro for each button and then the code goes where the button goes. This assuming the are all using a PK of the same name (which sounds like they are).

I mean no matter what you are going to need quite a few Forms with buttons in different places.
 
I mean no matter what you are going to need quite a few Forms with buttons in different places.
Maybe, but it would be interesting to experiment with a test db. I was thinking that if there weren't too many properties one could set it up as a table for each property and one that holds all forms data, assuming only command buttons need to be controlled, or just take a chance and create a flat table. If the max number of buttons for any pic required 10 buttons for example, then maybe it would look like this:

table1.jpg


I have done something similar but less complicated: All buttons were stacked in one location in design. Depending on which ones needed to be visible, those were moved into position using the topmost value + button height + spacing. Result was that if userA could see buttons 1, 2 and 5 and userB could see 3, 5 and 7 each set of 3 appeared in the same place rather than making some disabled (showing disabled features they might be curious about) or gaps because some were invisible.

I'm not convinced it's not doable yet, but I respect that the notion perhaps doesn't answer what's being asked for and I'm going to have to let this one go for now. My left ring finger is really starting to hurt when I type. Hint: wear gloves when pruning stuff you're holding in your hand, or at least keep your dang fingers out of the pruning shears.
 
So any ideas of how the code would look to do this in a module? Passing BldgAbb_ID from a form to a report?

How would I define the variables for this code? The BldgAbb_ID is text so I would set it to string but where would I go form here? I am opening a report based on the building abbreviation of a form. Thanks in advance for your help.
Code:
Option Compare Database
Option Explicit
Dim BldgAbb_ID As String

Private Sub cmdElev_Click()
On Error GoTo cmdElev_Click_Err

    DoCmd.OpenReport "rptElevators", acViewReport, "", "[BldgAbb_ID]=" & "'" & BldgAbb_ID & "'", acNormal

cmdElev_Click_Exit:
    Exit Sub

cmdElev_Click_Err:
    MsgBox Error$
    Resume cmdElev_Click_Exit

End Sub
 
Is the key for the report always the same?
Set a TempVar from the form BldgAbb_ID or pass it it in to the sub
Establish a naming convention.
So cmdElevator opens report rptElevator
Then you can either pass in the control name or again use a TempVar

In the Public Sub you would have something along the lines of

Code:
DoCmd.OpenReport "rpt"& Mid(ctrName,3), acViewReport, "", "[BldgAbb_ID]='" & BldgAbb_ID & "'"
Either way you have to tell the sub the arguments you want to use.?
 
Create a module so that you can use the variable in all forms and define a global variable inside this module. You can set the value of this variable no matter which form you go, you get a value in all forms and even in all reports.
Code:
Global ReportVariableID As Integer
 
Code:
conAppName = "(Replace this Local Variable with a Global One) "
So what should I do here? I modified your database below based on what I would need. Do you see any problems with what I did?
Thanks again this was awesome that you posted this db thanks!
 

Attachments

You can write a function that takes arguments. You could use a single function or a different one for each report.

However, there are far better ways to do this than to create a separate form for each piece of equipment. You could have used the picture to show based on the part selected. Then you'd have one form instead of hundreds. Rather than modifying the hundreds of forms to make the change to call standard functions, you should probably fix the underlying problem that caused you to think you needed hundreds of forms to begin with.
Basically one form for all the equipment. Problem is linking form multiple command buttons.
example to make it clearer
I try to make it simple......
Imagine a picture of a building with windows in a form...
Each window of the building has a transparent command button....
If you click on the window it brings up another form with who works in the office...
But you have many buildings each building completely shaped different.....
Some with hardly any windows and different people working in the offices....
So the command buttons could not be copied over as each building is completely different....
.
The form with all the people that work in the office is the same..Above is just a example of how it works.
 
You would probably pass the button name or its tag property value to the function so that anything that needs to be opened or referenced can be known by that reference.
FYI I feel like it might be perceived that I started something and then backed off wrt helping to implement it. The last week or so has been kinda nuts around here so my ability to follow through has been impacted. Sorry.
 
Don't worry about it everyone has been awesome to share their knowledge and time...
All the help over the past few months has helped me so much!!
 
If you need to lay the buttons over different places on each form, that is a situation that is more complex but which can still be solved with a single form. If the buttons are always in the same place and always mean the same thing, that is a problem that should be solved with a SINGLE form.

Which is it? We are 61 posts into this question and we still don't have a clear definition of your requirements.
Complex one need to lay the buttons over different places on each form.
 
So while I'm waiting for my android box to update, I have to wonder why
- there isn't a single form (or a set of base forms if for some reason they are so different - e.g. some require tab controls - maybe)
-
an image control is told what picture to load based on user demand (ud)
- ud therefore shows whichever buttons the table data determines and places them accordingly
- table data also provides one or more string parameters associated with each button to a function that controls what happens next. Perhaps the table data assigns a button Tag property value instead but who knows.

After 4 pages of responses I can't help but think that a course of action should have been arrived at quite some time ago. Maybe it's because the information has been coming in dribs and drabs, but if there was a complete explanation of the process at any point, it's buried in history and it seems it has been overlooked as the same questions and points continue to be asked/made.

Maybe what's needed is a sample db along with a couple of process pic files, some notes (or whatever it is that is supposed to appear on a few button clicks) along with anything else that's needed to set up maybe one form with 2 process examples and work out how to drive the process(es). Then OP would replicate.
 
I've put in a couple other questions in the test db if someone could answer. Remember this is just a quick test db so it can give you an idea of what would be the problem with just having one form (Relationships are a mess not at all like I have them). Thanks for the help.
 

Attachments

Last edited:
Sounds like a good idea but what about the note flag there might be lots of them as well.... I guess you could pick out one of the existing ones mapped out. Then the question of the size if I go too small or big with the text boxes. Great idea but its above my skill level to get this to work. Any ideas on the splash screen or search form? Thanks again for reviewing the db and the ideas...
 
At first glance I'd say don't expect an example real soon. It's all macros, which will have to be replaced with code if anyone here were to provide an example. As for your questions, I'll try to review them and post back with answers if possible.
 

Users who are viewing this thread

Back
Top Bottom