ControlSource Syntax

gray

Registered User.
Local time
Today, 22:44
Joined
Mar 19, 2007
Messages
578
Hi All

Access2002/2007
WinXpPro Sp2

Could someone help me sort out this syntax please?...

It's a Dcount in the controlsource of a textbox which needs to refer to the value in another textbox on the same form. I want it to re-'self-calculate' as the form is navigated along its records....

my_textBox.controlsource = "DCount('[Unique_No]','Addrs','[ID]'=[Me].[Form].[Form_Hdrs_ID_TextBox].Value)"


I've tried 10x10,000 permutations with commas, full-stops(periods), square brackets, parenthesees, exclamation marks (bangs), references to "me" references to "me.form", references to Forms!MyFormName.Form" blah blah ...... and still it fails with #Error or #Name. Maybe if I had enough monkeys, typewriters and the infinity of time I might get it right! :)

Thanks
 
in the controlsource property

=DCount("[Unique_No]","Addrs","[ID]=" & [ControlName])

As this is a calculation it should not be in a bound control
 
Referencing a control on the current record would simply be Me.YourControlName.

Is the ID field defined as a Number or Text Datatype? The syntax for this kind of thing varies depending on the Datatype.

Assuming that the control on the form is named

Form_Hdrs_ID_TextBox

If ID is Numeric

DCount("Unique_No", "Addrs", "[ID] = " & Form_Hdrs_ID_TextBox)

If ID is Text

DCount("Unique_No", "Addrs", "[ID] = '" & Me. Form_Hdrs_ID_TextBox & "'")

Linq ;0)>
 
Hi

Thanks gents...(it was a numeric BTW)...

I must be goiing daft tho' .. I'm sure I'd tried "& [ControlName])" .... more haste, less speed!

Cheers...
 

Users who are viewing this thread

Back
Top Bottom