473,396 Members | 2,108 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.

Change value using OnClick

4
I am a beginner user of Access. I have developed a database for a non-profit to manage contacts. I would like to change a value in a record by using OnClick. For example, If the value is "Member" I would like to change it to "Past Member" by clicking a label "Convert to Past Member"

Thanks
Len
Nov 14 '06 #1
12 17995
NeoPa
32,556 Expert Mod 16PB
You may find this link helpful (POSTING GUIDELINES: Please read carefully before posting to a forum).
If our experts don't understand your question, or don't find enough information to give a meaningful answer to, they may well move along to another thread.
We like to be helpful with answers where possible - the questions are down to you.

Len,
Your question is pleasingly brief, but doesn't give enough information.
Nov 14 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
I am a beginner user of Access. I have developed a database for a non-profit to manage contacts. I would like to change a value in a record by using OnClick. For example, If the value is "Member" I would like to change it to "Past Member" by clicking a label "Convert to Past Member"

Thanks
Len
Ok NeoPa is right but I'm going to make some assumptions.

Firstly I assume that you are not trying to change the whole record but just one value in one field on the record. As I don't know the name of the control for that field I'm just going to call it txtMemberStatus for now.

Although you can use a label for this purpose it's not normally done as users can click on labels accidently and not realise what they've done. Normally you would use a command button for this operation. Just drag one off the toolbar and cancel the wizard. For this example I will call it cmdChangeStatus.

Then just add the code so it looks as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdChangeStatus_Click()
  3.  
  4.     Me.txtMemberStatus = "Past Member"
  5.  
  6. End Sub
  7.  
  8.  
If you're not sure where to find this code. Open the properties window and click on the command button. Then under the event tab go down to On Click in the list. Make sure [Event Procedure] is selected and click on the button to the right.
Nov 15 '06 #3
lavdey
4
Ok NeoPa is right but I'm going to make some assumptions.

Firstly I assume that you are not trying to change the whole record but just one value in one field on the record. As I don't know the name of the control for that field I'm just going to call it txtMemberStatus for now.

Although you can use a label for this purpose it's not normally done as users can click on labels accidently and not realise what they've done. Normally you would use a command button for this operation. Just drag one off the toolbar and cancel the wizard. For this example I will call it cmdChangeStatus.

Then just add the code so it looks as follows:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdChangeStatus_Click()
  3.  
  4.     Me.txtMemberStatus = "Past Member"
  5.  
  6. End Sub
  7.  
  8.  
If you're not sure where to find this code. Open the properties window and click on the command button. Then under the event tab go down to On Click in the list. Make sure [Event Procedure] is selected and click on the button to the right.
That's great. Just what I needed. Sorry for the lack of detail and clarity.

Len
Nov 15 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
That's great. Just what I needed. Sorry for the lack of detail and clarity.

Len
No problem. It's for your own sake really. The more detail you give the quicker and more accurate answer you're likely to get.
Nov 15 '06 #5
missinglinq
3,532 Expert 2GB
Another hack that I've used for this task in the past uses the often overlooked "Double-Click" event of a textbox. When a text box only has two possible values, this allows you to set a default value (when the field is empty) and "toggle" between the two values when the field is filled in.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TextBoxEntry_DblClick(Cancel As Integer)
  2.      If IsNull(Me.TextBoxEntry) Then
  3.           Me.TextBoxEntry = "MEMBER"
  4.      ElseIf Me.TextBoxEntry = "MEMBER" Then
  5.           Me.TextBoxEntry = "PAST MEMBER"
  6.      ElseIf Me.TextBoxEntry = "PAST MEMBER" Then
  7.           Me.TextBoxEntry = "MEMBER"
  8.      End If
  9. End Sub 
Nov 15 '06 #6
MMcCarthy
14,534 Expert Mod 8TB
Another hack that I've used for this task in the past uses the often overlooked "Double-Click" event of a textbox. When a text box only has two possible values, this allows you to set a default value (when the field is empty) and "toggle" between the two values when the field is filled in.

Expand|Select|Wrap|Line Numbers
  1. Private Sub TextBoxEntry_DblClick(Cancel As Integer)
  2.      If IsNull(Me.TextBoxEntry) Then
  3.          Me.TextBoxEntry = "MEMBER"
  4.      ElseIf Me.TextBoxEntry = "MEMBER" Then
  5.          Me.TextBoxEntry = "PAST MEMBER"
  6.      ElseIf Me.TextBoxEntry = "PAST MEMBER" Then
  7.          Me.TextBoxEntry = "MEMBER"
  8.      End If
  9. End Sub 
Good workaround.

I must admit I often overlook the double_Click myself as why two clicks when one will do but there are obviouly times when it would come in useful. I have to start thinking about it more.

Mary
Nov 15 '06 #7
NeoPa
32,556 Expert Mod 16PB
Nice one ML.

I sometimes use that in my Excel work - when I'm too lazy to add a button, or it's to toggle a single value in a column.
Nov 15 '06 #8
missinglinq
3,532 Expert 2GB
as why two clicks when one will do
When doing this on a text box, you have to leave the single click alone so the user can "mouse" into the field if they want! The advantage of the method is that you save "real estate" that would be taken up with extra command buttons. I also use it for fields that need dates. I have a calendar control on the form that starts out being invisible. When the date field is double-clicked, the calendar becomes visible, the user picks a date, then the calendar becomes invisible again. Once again, a lot of space on the form is saved, and you're assured of the date being entered correctly!
Nov 16 '06 #9
MMcCarthy
14,534 Expert Mod 8TB
When doing this on a text box, you have to leave the single click alone so the user can "mouse" into the field if they want! The advantage of the method is that you save "real estate" that would be taken up with extra command buttons. I also use it for fields that need dates. I have a calendar control on the form that starts out being invisible. When the date field is double-clicked, the calendar becomes visible, the user picks a date, then the calendar becomes invisible again. Once again, a lot of space on the form is saved, and you're assured of the date being entered correctly!
I definately have to think about it more. All my calendars end up on popup forms for this very reason.

Mary
Nov 16 '06 #10
NeoPa
32,556 Expert Mod 16PB
I never use calendars myself, but this sounds like a very intelligent way to handle them.
Good for you ML.
Nov 16 '06 #11
lavdey
4
I want to thank you all for the great suggestions. Problem solved.

Len
Nov 21 '06 #12
MMcCarthy
14,534 Expert Mod 8TB
I want to thank you all for the great suggestions. Problem solved.

Len
No problem Len

We're glad to help.

Mary
Nov 21 '06 #13

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

Similar topics

8
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to...
8
by: KS | last post by:
Just to show some code to show the consept. <img id="date" onclick="javascript:show_calendar();" src="/PlexSysWeb/images/show-calendar.gif" width=20 height=18 border=0> What i want the...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
2
by: Nick Calladine | last post by:
Is this possible to ... I wish to get the value of a dropdown select but gets is indexable value (dont know if that is the right term) if that is possible (the position it assigned get assigned...
2
by: Cranky | last post by:
Ok, here is my scenario: I need to input numbers using my handheld IPAQ. I figured out how to create an online numeric keypad for inputting numbers into an input field, what I need to know is how...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
3
by: jnag | last post by:
Hello, I have a website with various font options (small to large) buttons that the user can click on the banner, which runs through the site. Site contains both static and dynamic content. I...
5
by: thatcollegeguy | last post by:
Below are my 3php and 2js files. I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.