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

Change value using OnClick

P: 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
Share this Question
Share on Google+
12 Replies


NeoPa
Expert Mod 15k+
P: 31,489
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
Expert Mod 10K+
P: 14,534
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

P: 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
Expert Mod 10K+
P: 14,534
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
Expert 2.5K+
P: 3,532
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
Expert Mod 10K+
P: 14,534
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
Expert Mod 15k+
P: 31,489
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
Expert 2.5K+
P: 3,532
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
Expert Mod 10K+
P: 14,534
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
Expert Mod 15k+
P: 31,489
I never use calendars myself, but this sounds like a very intelligent way to handle them.
Good for you ML.
Nov 16 '06 #11

P: 4
I want to thank you all for the great suggestions. Problem solved.

Len
Nov 21 '06 #12

MMcCarthy
Expert Mod 10K+
P: 14,534
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

Post your reply

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