473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

vba code to change a field based on another field

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?

5 6879
NeoPa
32,556 Expert Mod 16PB
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
jolaunt
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
2,322 Expert Mod 2GB
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
jolaunt
16
Thank you this worked perfectly! :-)
Apr 19 '10 #5
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
2
by: Danny | last post by:
Hello I am trying to create a separate listbox and fill it with items based on what is in another field in a database. This field is bound to a field in the underlying database. But the data...
3
by: Iain Miller | last post by:
Can anybody help me with some Access 2000 code? I don't do a lot of coding in Access & so every time I come back to do something I pretty much have to relearn the syntax from scratch so this is...
5
by: bruboj | last post by:
I created an audit trail for my access 97 database using code I found at: http://members.iinet.net.au/~allenbrowne/AppAudit.html One of the limitations stated for the code is "each table to be...
8
by: Steph | last post by:
Hi. I'm very new to MS Access and have been presented with an Access database of contacts by my employer. I am trying to redesign the main form of the database so that a button entitled...
1
by: Tony | last post by:
Hi, I have two forms A and B, both opened. In form A, I programmatically change the Date of Birth field of the current record of form B. I noticed that form B automatically displays the new data...
4
by: robtyketto | last post by:
I have generated combo boxes based on contents of other combos and am newbie who slowly learning vba code. Heres an example of vba code use to update one combo box from another ...
5
by: Rex | last post by:
Hi, I want to change a value in one table depending on the value(s) in another table. I am trying to achieve this in a form. to elaborate I have a many-to-many relationship between tables...
5
by: datasec23 | last post by:
Hi...I am trying to get my listbox data to change based on a field on a form. Each time I click on the next record indicator at the bottom of the form, I would like the Listbox to change...
8
by: joshapalooza | last post by:
Hi all, What I'm trying to do is two-fold. We'll tackle one and then the other, or whichever is easiest. First Question/Problem: Is it possible to write VBA code that would change a text...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.