What do you mean by custom properties Uncle G?I use the method when I pass variables via custom properties of a form. Strangely the forms "on load" and "on open" Events happened before the custom properties are set which is very annoying.
What do you mean by custom properties Uncle G?I use the method when I pass variables via custom properties of a form. Strangely the forms "on load" and "on open" Events happened before the custom properties are set which is very annoying.
It's good that you're learning VBA.
Forms is a collection of loaded forms in your db. A loaded form is one that is open in any view, i.e. design, single form, continuous form etc. When you enter the name of a form in Forms() you are referring to that particular form; regardless of which form the code is being run. The same thing goes for Controls(); it's a collection of controls in the form.
Now in your case, strFormName is a variable that holds the name of the menu form that you're opening, so in order to reference the label in the menu form we first refer to the form (i.e. Forms(strFormName)), followed by a dot, and then the name of the label (i.e. Controls("Name of label")). If you put all that together you get the code above.
I hope it makes sense.
I was starting to get it but then I noticed you mention [label in menu form] The label is in the main data form. The string I put in the fx [.fX ("Supporting Churches")] is what needs to show up in the lbl on the main form. Please lay it on me again with that thought in mindIt's good that you're learning VBA.
Forms is a collection of loaded forms in your db. A loaded form is one that is open in any view, i.e. design, single form, continuous form etc. When you enter the name of a form in Forms() you are referring to that particular form; regardless of which form the code is being run. The same thing goes for Controls(); it's a collection of controls in the form.
Now in your case, strFormName is a variable that holds the name of the menu form that you're opening, so in order to reference the label in the menu form we first refer to the form (i.e. Forms(strFormName)), followed by a dot, and then the name of the label (i.e. Controls("Name of label")). If you put all that together you get the code above.
I hope it makes sense.
Yes you were getting it, that was supposed to say "Main form".
If you want to drive a car, you have to get in the car to drive it right? Then once you're in the car, you can change gears, change the direction of the steering wheel etc. Now the form is your car, in order to change the property of one the controls in the car, you need to first access that form. That's why you do this Forms(strFormName) to access the form, followed by a dot, then to access the controls, i.e. textbox; label etc, you write Controls("Label Name") afterwards.
You set the caption after opening the form.
'------------------------------------------------------------
' TRYING SHORT VBA
' cmdSupportingCh_Click via Dick's Main menu
'opens church form filtered with just supporting churches
'------------------------------------------------------------
Private Sub cmdSupportingCh_Click()
Dim strFrmName As String
strFrmName = "frmChurchesAllDick"
DoCmd.OpenForm strFrmName
DoCmd.ApplyFilter "qrySupportingCh"
Forms(strFrmName).Controls("lblSupportingCH").Caption = "Supporting Churches" ' DoCmd.Close acForm, "frmMainMenuDick", acformyes
End sub
Check that the Visible property of the label is set to True.
So after setting it back to Yes you're back up and running?
Actually they are dark green. They came out that way when I zipped them.I can't see any of the code suggested in the db. Can you upload something with your trials that isn't working.
By the way, how do you manage to read those command buttons with the pale yellow fore colour?![]()
You mean the dialog box is a parameter in your query?If you still have that menu form it has a cmd for states. Is it possible to pick up the 2 letter abbreviation of whatever state (FL, MS etcs.) I query in the dialog box and put it in the label?
That's kind of you. I was in the LA and Vegas last year... might be going to NY later this year.Ps. if you ever come to FL (when I am home, I am in MS right now) I will treat you to the best Chines Buffet in the whole US and TX.
Don't know as I have never eaten @ a Chinese Buffet in London, but I have eaten in Chinese Buffets in 33 states in US. In fact I can't even remember much of what I ate in UK. Of course I was only 19, so all I remember that a young woman took me drinking and she ordered us a pims #1 or 2. Or something like that.Yeah, I noticed that you had saved "Supporting
Yes, sometimes I look for churches by state. In fact I just had to send a associate a list of all the churches I had for AZ. So is it possible to have my label show what state I enter in?You mean the dialog box is a parameter in your query?