RetainSameConnection property on project-level connections.
If I change to true (from default of false) and choose not to save the package file I used to make the change then the setting will be retained but none of the files in source control have changed. Where is this value being stored?!
Value is stored even after closing/reopening VS and restarting machine.
Also:
If you specify RetainSameConnection=true at the project-file level (.dtproj) the RetainSameConnection property drop-down (viewed via Properties tab) in VS will show false but the behaviour will be true. While I would expect behaviour to be true it's misleading that the drop-down value doesn't conform & I'd like to understand why it doesn't.
If you create a boolean project param with value of true & parameterise RetainSameConnection property of the project connection then behaviour will be true and you can no longer change the value of the drop-down. This is exactly what I'd expect.
If you edit and save the connection properties it will set DTS:Retain="True" on the conmgr file. This again doesn't cause the drop-down value to change. haven't experimented with this as am losing the will slightly.
Related
I rarely use VBA Access for maintaining our legacy application. I am using MS Access 2007. I am trying to use tri-state in a text-box input. In other words, I have a textbox input that is bind to Boolean field (HOME which is bit with allow NULL in SQL Server) in database; however, I need to show 1 not -1 for true when user enter 1. Similarly, there should be 0 for "false" when user enters 0 in database. The last case is: it should save Null in database if user enter nothing or space.
What I did so far:
Under Property Sheet for this textbox:
Under Format tab, I set Format field to nothing instead of true/false, on/off or yes/no as I need three state.
Under Data tab, bind Control Source to Home field.
Under other tab of property, I set Status Bar Text to 1=HOME, 0=Not HOME
Problem :
When I enter 1, textbox is displaying -1 and it saves 1 in table which is good.
When I enter 0, textbox is displaying 0 and saving 0. So, this case is good.
When I try to enter nothing or space, it takes 0 by default.
Can anyone please tell me how do I achieve the three state for my Boolean text-box? or redirect me to the link here in Stack Overflow because I couldn't find one when I was researching in SO.
Set the Format property of the textbox to: 0,0 or to: 0;0
Also, set the DefaultValue of the field to Null.
Try adjusting your Sub "up/down":
Private Sub txtHome_AfterUpdate()
If Me!txtHome.Value = "" Then
Me!txtHome.Value = Null
End If
End Sub
Per reading different online articles and Posts, I believe it is not possible to have tri-state in MS ACCESS. In other words, MS Access will take "NULL" as FALSE and save False/0/No in database. I thought of keeping it in here so that it might be helpful to some other people if they are struggling on it.
I've created a function that attempts to return a SubForm data type. This function is used by various parent Forms.
The function looks like this:
Public Function mySubFrm(name As String, subformName As String) As SubForm
Dim frm As Form
Dim subFrm As SubForm
Set frm = Forms(name)
Set subFrm = frm.Controls(subformName)
mySubFrm = subFrm
End Function
I've attempted to use it by the following:
Dim testSubForm As SubForm
testSubForm = mySubFrm("testForm", "testSubForm")
Immediately, it follows with compile error:
Invalid use of property
What I've attempted to do was add a watch at frm.Controls(subformName) and I see its return type is SubForm/SubForm, so I feel as though I am declaring and setting the right data type, but then again I'm not sure?
Can someone assist me with what I'm not doing properly?
Thanks
I don't know much Access, but I know VBA pretty well.
Your function is returning an object reference:
Public Function mySubFrm(name As String, subformName As String) As SubForm
As such, its return value must be assigned using the Set keyword:
Set mySubFrm = subFrm
The reason why you're getting this confusing error, is because of a lovely (not!) thing in VBA called default properties.
See, a form has a default property, most likely its Controls collection - and that property is only exposing a Public Property Get accessor, which makes it read-only.
So when you omit the Set keyword:
mySubFrm = subFrm
VBA assumes the code is legal, and so the only thing you could possibly be wanting to do, is to assign that default property - in other words, it's behaving exactly as if you would have written:
mySubFrm.Controls = subFrm
But the Controls class' own default property is its Item member, which is also read-only: there's no way the default Controls property can appear on the left-hand side of an assignment.
Hence, invalid use of property.
My open-source project Rubberduck will soon have an inspection that will issue a result whenever you're implicitly referring to an object's default property, offering to make the call explicit. Writing code that says what it does, and does what it says is hard when you don't even know you're referring to a default property.
You receive the error because you're trying to set an object, but are not using the Set keyword.
Perhaps it should be the following:
Set mySubFrm = subFrm
Or
Set mySubFrm = frmDatasheet
I would like to suggest a different approach. Typically when you create a form with a subform, it's quite rare that you actually need the subform to be dynamic. There is almost always a relationship between the parent form and the child form, and I would consider a parent form without its child a broken object in general.
Therefore, when I need to access things that's on the subform, I prefer to use the explicit version:
Dim mySubForm As Access.SubForm
Set mySubForm = Me.Controls("mySubForm").Form
mySubForm.SomeControlOnMySubForm.Value = 123
Yes it's 3 lines now but the advantage is that the reference to a specific form is now made explicit in your parent form. You now can see from the code that the parent form depends on that subform. More importantly, if you delete or rename the control SomeControlOnMySubform, the above form will allow the VBA compiler to warn you that there is no such object on the subform, enabling you to verify your code.
In other words, try your best to convert any potential runtime errors into compile-time errors because compile-time errors are much easier to validate and prevent than runtime errors.
The same principle works in the reverse; when you want to describe your subform as explicitly depending on a parent form, you can do:
Dim myParent As Form_frmParent
Set myParent = Me.Parent
NOTE: The code all assumes that there are code-behinds for all forms involved. If a form has no code-behind, it won't have a VBA class for you to reference. In such case, I set the form's property HasModule (located in the Others tab) to Yes even if there's ultimately no code-behind. (The reason is that it used to be that you could create "lightweight" form by creating it with no code-behind but with modern hardware, there is hardly any difference)
I am calling a stored procedure in a data flow task that outputs a value that is not being used. Because its not being used the optimizer removes the component during runtime. It states I can override this by setting the 'HasSideEffects' property to true but I don't see where to set this. I see it in the 'Input and Ouput Properties' of the OLE DB Source but its read only.
Turns out that I had set the 'RunInOptimizedMode' property to true and that was causing the issues. Set it to false and I am good to go
How do I refer to a report's controls explicitly? Referring implicitly works as expected:
Me.lblTest.Visible = True
However, all of my attempts at referencing the control explicitly meet with various nonsensical runtime errors. Access' favorite:
"The report name 'rptTest' you entered is misspelled (it's not) or refers to a report that isn't open (it is) or doesn't exist (it does)."
I've tried a dozen syntax variations from MSDN and everywhere else I could find, all producing errors:
Reports!rptTest.lblTest.Visible = True
' ^--expected syntax, like Forms!frmName.ctlName.Property
Reports!("rptTest").lblTest.Visible = True
Reports![rptTest].lblTest.Visible = True
Reports("rptTest").Controls("lblTest").Visible = True
etc. etc.
This should be no different from referring to forms' controls, right? There must be a way to refer explicitly to a report's controls.
Check the names of the reports Access thinks are open.
With your report open, go to the Immediate window. Ctrl+g will take you there.
Paste in for each rpt in reports : ? rpt.name : next as one line and press Enter. Access will tell you the names of the open reports as it sees them.
Here is an Immediate window example from my system with one report, rptFoo, open ...
for each rpt in reports : ? rpt.name : next
rptFoo
The problem you're facing is that rptTest is open, but Access disagrees. That discrepancy can be caused at least 3 ways:
rptTest is what you see when the report is open, but that is the report's Caption property instead of its Name
rptTest is a subreport contained in some other open report. The Reports collection, which is where Access looks to find open reports, contains only the "top-level" reports which are open. If you're dealing with a subreport, reference it via its parent report ... Reports!rptParent!SubreportControl!lblTest.Visible where SubreportControl is the name of the subreport control which contains rptTest. Be careful because the name of that subreport control may not be rptTest --- you need the name of the subreport control, not the name of the report it contains.
If rptTest is contained in a subform/subreport control within a form (instead of within a report), the situation is similar to #2, but you must reference it via its parent form ... Forms!YourFormName!SubcontrolName!lblTest.Visible
When i tried to give connection string in the form of a variable to "Excel Connection Manager", it gives me the below error.
the connection string format is not valid. it must consist of one or more components of the form x=y seperated by semicolons. This error occurs when a connection string with zero components is set on database connection manager.
Since you want a dynamic file path, when you are setting up the Expression for the Excel Connection Manager, you are probably selecting ConnectionString as a property in the Property Expressions Editor. This results in the error you specified in your question.
What you actually need to select is the ExcelFilePath property. Add your variable in the Expression field afterwards as you would normally do.
You should give us more information. What's the value of you variable when the error pops up? To exactly what property have you assigned this variable?
Anyway, I suspect that you didn't set [Delay validation] property of your connection manager to True - without it ssis check if you connection manager is ok, before you even assign value to the variable (which is dynamic and happens during execution in some loop, I suppose).