By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,454 Members | 2,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,454 IT Pros & Developers. It's quick & easy.

vba code to change a field based on another field

P: 16
I am trying to create a vba code to tick a box after an update of another box.

I have a yes/no drop down box called 'ResolvedByTelCall'. When 'yes' is selected I want a tick to go in another box called 'Resolved'.

I have tried using the following code which does nothing:
Expand|Select|Wrap|Line Numbers
  1. Private Sub ResolvedByTelCall_AfterUpdate()
  2. If Me.ResolvedByTelCall = True Then
  3. Me.Resolved = True
  4. End If
  5. End Sub
I am quite new to this and would appreciate any help!!

Thanks in advance.
Apr 16 '10 #1

✓ answered by TheSmileyCoder

Try
Expand|Select|Wrap|Line Numbers
  1. Private Sub ResolvedByTelCall_AfterUpdate() 
  2.   If Me.ResolvedByTelCall = "Yes" Then 
  3.     Me.Resolved = True 
  4.   End If 
  5. End Sub 
If that doesn't work, you will need to provide more info on the structure of your drop down (usually referred to as a combobox, since thats what access calls it)

The box you want to "tick" is that a Checkbox bound to a yes/no field?

Share this Question
Share on Google+
5 Replies


NeoPa
Expert Mod 15k+
P: 31,186
If you have a Drop Down (or ComboBox) then the chances are the values held will be strings rather than boolean or numeric. Your code compares the value to True (which is a boolean value that is numerically equivalent to -1 - or all 1 bits). The value Yes is True. But the value "Yes" is certainly not. Does that make sense?

Welcome to Bytes!
Apr 16 '10 #2

P: 16
Sorry I am a newbie and a little confused by this.

How do I get around this? Should I change the format of my yes/no box?

Your help is appreciated
Apr 16 '10 #3

TheSmileyCoder
Expert Mod 100+
P: 2,321
Try
Expand|Select|Wrap|Line Numbers
  1. Private Sub ResolvedByTelCall_AfterUpdate() 
  2.   If Me.ResolvedByTelCall = "Yes" Then 
  3.     Me.Resolved = True 
  4.   End If 
  5. End Sub 
If that doesn't work, you will need to provide more info on the structure of your drop down (usually referred to as a combobox, since thats what access calls it)

The box you want to "tick" is that a Checkbox bound to a yes/no field?
Apr 16 '10 #4

P: 16
Thank you this worked perfectly! :-)
Apr 19 '10 #5

NeoPa
Expert Mod 15k+
P: 31,186
It looks like your ComboBox is populated with string (text) data then. In that case some very simple code should both set and reset it for you :
Expand|Select|Wrap|Line Numbers
  1. Private Sub ResolvedByTelCall_AfterUpdate()
  2.   Me.Resolved = (Me.ResolvedByTelCall = "Yes")
  3. End Sub
Apr 19 '10 #6

Post your reply

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