Set a Control Value on Current Datasheet Record (1 Viewer)

whdyck

Registered User.
Local time
Today, 01:47
Joined
Aug 8, 2011
Messages
169
Bonehead question here:

In a datasheet, how can I get VBA to set an unbound control's value on only the current record, but none others?

Thanks.

Wayne
 
Last edited:

bob fitz

AWF VIP
Local time
Today, 07:47
Joined
May 23, 2011
Messages
4,726
Maybe something like:

Me.ControlName = "NewValue"

in the forms OnCurrent event
 

whdyck

Registered User.
Local time
Today, 01:47
Joined
Aug 8, 2011
Messages
169
I have tried that, but it sets the value for all records in the datasheet.
 

bob fitz

AWF VIP
Local time
Today, 07:47
Joined
May 23, 2011
Messages
4,726
I have tried that, but it sets the value for all records in the datasheet.
Did you try it in the ON Current event of the form and are you sure that the form is in datasheet view
 

missinglinq

AWF VIP
Local time
Today, 02:47
Joined
Jun 20, 2003
Messages
6,423
I have tried that, but it sets the value for all records in the datasheet.

That's correct...you can only do this kind of thing, using the Form_Current event, on a Single View Form. Doing it using the Form_Current event, on either Datasheet or Continuous View Forms, will set that Control on all Records to the Value that is appropriate for the Current Record.

To make the value of an Unbound Control appropriate to a given Record, on Datasheet or Continuous View Form, you have to use its Control Source Property. If you wanted the Unbound Control to display a sales tax of 5%, say, and the calculation was

ItemCost * 0.05

then in the Control Source Property you'd enter

=[ItemCost] * 0.05

If you're saying that you only want a Value to appear in that Unbound Control on the Current Record, but nothing to appear in that Control on any other Record, I can't think of a way to do that, nor, to be honest, imagine why you'd need to.

What, exactly, do you want to display in this Control?

Linq ;0)>
 
Last edited:

Users who are viewing this thread

Top Bottom