469,903 Members | 1,807 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

How to update only one field in a form? (DLookup / recalc / requery)

15
Hello,

On an LostFocus event I'm trying to update another field that is tied to a DLookUp query.

I'm able to update all the form fields but I don't find a way to update only one field.

The below tests update all the fields
Expand|Select|Wrap|Line Numbers
  1. - Me.Recalc
  2. - Me.Controls("Txtbox_RatioDev2").Recalc
  3. - Me.Requery
  4. - Me!Txtbox_RatioDev2.Requery
  5. - Forms("Description").Controls("Txtbox_RatioDev2").Requery
  6.  

Theses examples are not working:
Expand|Select|Wrap|Line Numbers
  1. - Me.Controls("Txtbox_RatioDev2").Recalc
  2. - Forms("Description").Controls("Txtbox_RatioDev2")
  3.  
So is it possible or am I stuck to requery and so update all the form?

Thanks.
Jun 23 '09 #1
6 9299
ADezii
8,800 Expert 8TB
@deewe
The Recalc Method will immediately Update all Calculated Controls on a Form. It applies only to a Form, so individual Controls cannot be Recalculated.
Jun 23 '09 #2
deewe
15
@ADezii
Thanks for the highlight!

I guess it's the same for the Requery Method then.
Jun 23 '09 #3
yarbrough40
320 100+
try it without "!" and use "."
Expand|Select|Wrap|Line Numbers
  1. Me.Txtbox_RatioDev2.Requery
  2.  
if that doesn't work.. what WILL work is retyping the formula for that control's value
Expand|Select|Wrap|Line Numbers
  1. Me.Txtbox_RatioDev2.Value = DLookup("[SID]", "UserTable", "[PrimKey] = 3")
  2.  
Jun 24 '09 #4
ADezii
8,800 Expert 8TB
What will work is Saving the Record, then Requerying the Control:
Expand|Select|Wrap|Line Numbers
  1. SendKeys "+{ENTER}", True
  2. Me![txtTest].Requery
Jun 24 '09 #5
deewe
15
@ADezii
Hello Adezii,

I tested it and it still updates all fields in the from. No big deal though.
Jun 25 '09 #6
yarbrough40
320 100+
Again - you may have to simply send the value of the control again (see my code suggestion above) I promise it works!
Jun 25 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by gthompson | last post: by
6 posts views Thread by eclypz | last post: by
4 posts views Thread by bobchabot | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.