I am getting the following error:
The expression you entered has an invalid reference to the parent property
On the following IF condition, the issue occurs on focus of a Textbox
If Me.AB.Value <> "" And Me.Parent.Respondent = "County of ABC" And (Me.AB.Value <> GenAB) Then
End If
A control (in this case, the textbox) has the form as it's parent, so you can reference properties of the parent (the form) when you're looking at the parent relative to the control. However, you're referring to the control from the perspective of the form --> the "Me" object, so when you refer to "Me.Parent", your asking the code to look for the parent of the form, not the textbox.
If you're looking for a control on a parent form to a subform, then it looks like your reference to "Respondent" may be the issue. Try referring to it as "Me.Parent.Respondent.Value" instead.
Also, if "Respondent" is allowed to be NULL, the if statement comparison can also fail. In those cases, I append a zero-length string to ensure the result is STRING data:
If Me.Parent.Respondent.Value & "" = "ABC" Then
Related
I comment, and looked here and I can not find the solution, my problem is the following:
in my html template in angular, I need to pass a series of data to the metadata property of a button, I can't get the correct way to successfully concatenate the variable that contains the value.
this should be the html element:
<mati-button clientId="clientId" flowId="flowId" color="green"metadata='{"user_id":"1234778","email":"som#som.com"}'/>
I tried several ways but I can't insert the respective values....
example:
<mati-button metadata='{"userID": "{{user.id}}" }'></mati-button>
unsuccessfully...
Assuming mati-button is an Angular component with metadata as Input(), you are probably looking for
<mati-button
[clientId]="clientId"
[flowId]="flowId"
[color]="green"
[metadata]="{ userId: '1234778', email: 'som#som.com'}"
></mati-button>
See the guide on property binding to learn more:
To bind to an element's property, enclose it in square brackets, [], which identifies the property as a target property. [...] The brackets, [], cause Angular to evaluate the right-hand side of the assignment as a dynamic expression. Without the brackets, Angular treats the right-hand side as a string literal and sets the property to that static value.
By "dynamic expression" they mean JS-expressions, i.e., a public variable available through the component's TypeScript, a boolean expression, an array, or, like in your case, a JS-object that you can construct inline.
You can try doing this
<mati-button metadata="{'userID': user.id }"></mati-button>
metadata='{" userID ": {{user.id}}}'
in the end I got it. Apparently I don't know why, but the third-party script hides that parameter and it couldn't be debugged in the console, but it does receive them without any problem! Thanks everyone for your help!
I have a Sub Form in MS Access as below :
Is there any way to get the string value of the selected row when the user click on the row ?
I have tried using the ReportKey as follow :
SELECT MyRowName From TAB_MySubFormName WHERE TAB_MySubFormName.ReportKey=" & ReportKey
but the result of the ReportKey is always 1 which I guess it's the first element even thought I have clicked on the last element in the table
I end up finding my error
I had to precise the SUB_Form.Form.ReportKey no need to precise the sub form name just simply add SUB_Form.Form.ReportKey , which means I had to do this :
SELECT MyRowName From TAB_MySubFormName WHERE TAB_MySubFormName.ReportKey=" & SUB_Form.Form.ReportKey
Try this code in your main form:
MsgBox Nz(Me.YourSubform.Form!SomeField)
This is a follow up to a previous question I asked about how to update a textbox while typing. In my previous question, I had three textboxes, two of which were enabled and one which was not. They look like this:
My goal is to use the First and Last Name of the two textboxes to fill a "Code Personal" in the other textbox. As I type the first and last names, I want the Code Personal textbox to update immediately, with the format of LLLLLL_F (eg: BERNAS_P). However, whenever I try to update the Code Personal textbox, I receive this error:
The code I use to create the Code Personal format and to update the textbox is:
Private Sub TxtFName_Change()
firstName = Me.TxtFName.Value
lastName = Me.txtLName.Value
firstPart = Left(lastName, 6)
secondPart = Left(firstName, 1)
nameCode = firstPart + "_" + secondPart
upperNameCode = UCase(nameCode)
txtCodePersonal.Text = upperNameCode 'My debug tells me I have an error here
End Sub
I've tried to set the focus to the txtCodePersonal textbox through: [txtCodePersonal].SetFocus, but I still receive an error (MS Access can't move the focus to the control txtCodePersonal.)
Any Ideas as to how I can update the "Code Personal" textbox while typing in the other two textboxes?
Thanks in advance for all your help.
Do your value assignment to the text box's .Value property instead of its .Text property. Either of these should work:
Me.txtCodePersonal.Value = upperNameCode
Me.txtCodePersonal = upperNameCode
.Value is the default property for a text box, so you don't need to include it explicitly. Include it if you feel it makes the code clearer.
This question is mainly for curiosity, but also, in the description, I had intended to highlight an infrequently documented behavior of Access.
Background
When creating an Access report, we can use the On Format method of the detail section to modify values or properties per-record. For example, assume we want to hide a field label when the value is empty:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If (IsNull(Me.SomeField) Or Me.SomeField = "") Then
Me.SomeFieldLabel.Visible = False
Else
Me.SomeFieldLabel.Visible = True
End If
End Sub
What I did not realize about this until today is that the assignment .Visible = False does not modify the instance of the label in the Detail section, but rather is modifying the definition of the label on the report.
This can be demonstrated with the following modifiction to the code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
If (IsNull(Me.SomeField) Or Me.SomeField = "") Then
Me.SomeFieldLabel.Visible = False
End If
End Sub
Assuming the label is initially visible (in form Designer), the event produces somewhat unexpected behavior: the label will remain visible until the first empty record; after that, it will remain hidden for all other records - I had originally expected that at each call of Detail_Format the controls where starting with their default definitions.
Question
Is there any way to reference the particular instance of a control within the Detail_Format event?
In this simple case of visible true/false, this is easily handled by just a simple if-then-else, but I can imagine more advanced scenarios where one might want to leave the default values in tact.
I don't believe so, in all of my experience, properties of report objects always apply universally across the report, not to specific instances of the abject (if the object is repeated).
For your example, I would use a text box instead of a label to label the field, and use something like =IIf(IsNull(Field1), "", "Label:") for the controlsource. That way it won't show anything if the field is null, yet still show the label text if there is a value.
I have a textbox on a subform the controlsource property of which is to be changed on click of a label on the parent form of the same. I have tried the following ways none of which worked at all,
Form_frmWOMAINMENU.[frmWOMAINSUBMENU].Form.[txtDate].Control.ControlSource _
= "Raised"
Forms("frmWOMAINMENU").[frmWOMAINSUBMENU].Form.[txtDate].ControlSource _
= "Raised"
Me.[frmWOMAINSUBMENU].Form.[txtDate].ControlSource = "Raised"
Can anyone suggest me how it works?
frmWOMAINMENU is the parent form and frmWOMAINSUBMENU is the subform.
Also, "Raised" comes from a sql query written as string in the vba code.
I tried the same in the subform like this:
me.txtDate.ControlSource="Raised"
and it worked fine.However,I cannot change control source of the textbox thrice in the subform.
It will be more like:
Forms!frmWOMAINMENU!frmWOMAINSUBMENU!txtDate.ControlSource = "Raised"
As long as on your parent form, the actual sub-form item is named "frmWOMAINSUBMENU" rather than "Subform1" or whatever the default naming is. Or in other words, the parent form is referred to by name and then the sub-form is referred to as whatever it's called on the parent form. Hope that makes sense : )