Greetings,
I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes. I have three combo boxes ("FY", "Qtr" and "Mth") that contain the values for a project's deadline: fiscal year, quarter and month, respectively.
My goal is to build an AfterUpdate event procedure such that when a user changes a value for any of the three aforementioned combo boxes, an automatic change will occur to the value in a fourth combo box (named "Status"), changing its value to a pre-determined setting (in this case, "Yellow"), which is sourced from a query ("QryUniqueStatus").
Whatever help you can offer would be most appreciated.
Regards,
- JM
8 11957
Greetings,
I have an Access 2002 continuous form called "Project Update Form" in which users can update project values presented in a series of combo boxes and text boxes. I have three combo boxes ("FY", "Qtr" and "Mth") that contain the values for a project's deadline: fiscal year, quarter and month, respectively.
My goal is to build an AfterUpdate event procedure such that when a user changes a value for any of the three aforementioned combo boxes, an automatic change will occur to the value in a fourth combo box (named "Status"), changing its value to a pre-determined setting (in this case, "Yellow"), which is sourced from a query ("QryUniqueStatus").
Whatever help you can offer would be most appreciated.
Regards,
- JM
One thing is not clear....Do you want the background color in Status to change to yellow or do you want the Status to say "Yellow"? In any event, the easiest way to accomplish what you want would be to enclose the 3 combo boxes in an option group frame from Access's toolbox. Once you do that, you will be able to code for a change in any of the 3 comboboxes in the AfterUpdate of the option group. If you need further assistance with the code,post back.
One thing is not clear....Do you want the background color in Status to change to yellow or do you want the Status to say "Yellow"? In any event, the easiest way to accomplish what you want would be to enclose the 3 combo boxes in an option group frame from Access's toolbox. Once you do that, you will be able to code for a change in any of the 3 comboboxes in the AfterUpdate of the option group. If you need further assistance with the code,post back.
I enclosed the 3 combo boxes in an option group frame but could use your assistance with the AfterUpdate code.
Thanks,
- JM
P.S. I want the Status to change to the value "Yellow" (not the color).
I too would love to see this code since i am doing the same with aome combo boxes of mine. By the way this forum is the best... Thanks guys for the hard work you put in.
Ok, let's get started with code, The code has to be improvised because (as you know) comboboxes are not one of the default options provided by the option group frame. So, if you've taken the first step of placing an option group frame around your 3 comboboxes, you had to select either option buttons, checkboxes, or toggle buttons. So at this point you should have a buttons or checkbox next to each of your comboboxes. Here is the steps you need to take to simulate the option buttons with your comboboxes.
1. Delete all of the buttons or checkboxes, and their labels.....you won't be needing them.
2. Let's assume that the option group frame is named optGrpProject and the comboboxes are named cbo1, cbo2, and cbo3.
3. code onGotFocus events for each of the comboboxes, assigning a value that is passed on to the option group. Note that the AfterUpdate event for the option group is called after the option group value has been assigned. The AfterUpdate has to be called because it does not fire if the update is made via code instead of via data input. -
Private Sub cbo1_GotFocus()
-
Me.optGrpProject.Value = 1
-
optGrpProject_AfterUpdate
-
End Sub
-
-
Private Sub cbo2_GotFocus()
-
Me.optGrpProject.Value = 2
-
optGrpProject_AfterUpdate
-
End Sub
-
-
Private Sub cbo3_GotFocus()
-
Me.optGrpProject.Value = 3
-
optGrpProject_AfterUpdate
-
End Sub
-
-
4. Code the AfterUpdate event of the option group. After this has been coded and tested, let me know any refinements you want to make.
-
-
Private Sub optgrpProject_AfterUpdate()
-
' capture the option group value selected and proceed accordingly
-
-
On Error GoTo Error_Routine
-
-
Select Case Me.optgrpProject.Value
-
Case 1 'status is yellow
-
Me!cboStatus = "Yellow"
-
Case 2 'status is blue
-
Me!cboStatus = "Blue"
-
Case 3 'status is green
-
Me!cboStatus = "Green"
-
End Select
-
-
-
Exit_Continue:
-
Exit Sub
-
-
Error_Routine:
-
MsgBox "Error# " & Err.Number & " " & Err.Description
-
Resume Exit_Continue
-
-
End Sub
Ok, let's get started with code, The code has to be improvised because (as you know) comboboxes are not one of the default options provided by the option group frame. So, if you've taken the first step of placing an option group frame around your 3 comboboxes, you had to select either option buttons, checkboxes, or toggle buttons. So at this point you should have a buttons or checkbox next to each of your comboboxes. Here is the steps you need to take to simulate the option buttons with your comboboxes.
1. Delete all of the buttons or checkboxes, and their labels.....you won't be needing them.
2. Let's assume that the option group frame is named optGrpProject and the comboboxes are named cbo1, cbo2, and cbo3.
3. code onGotFocus events for each of the comboboxes, assigning a value that is passed on to the option group. Note that the AfterUpdate event for the option group is called after the option group value has been assigned. The AfterUpdate has to be called because it does not fire if the update is made via code instead of via data input. -
Private Sub cbo1_GotFocus()
-
Me.optGrpProject.Value = 1
-
optGrpProject_AfterUpdate
-
End Sub
-
-
Private Sub cbo2_GotFocus()
-
Me.optGrpProject.Value = 2
-
optGrpProject_AfterUpdate
-
End Sub
-
-
Private Sub cbo3_GotFocus()
-
Me.optGrpProject.Value = 3
-
optGrpProject_AfterUpdate
-
End Sub
-
-
4. Code the AfterUpdate event of the option group. After this has been coded and tested, let me know any refinements you want to make.
-
-
Private Sub optgrpProject_AfterUpdate()
-
' capture the option group value selected and proceed accordingly
-
-
On Error GoTo Error_Routine
-
-
Select Case Me.optgrpProject.Value
-
Case 1 'status is yellow
-
Me!cboStatus = "Yellow"
-
Case 2 'status is blue
-
Me!cboStatus = "Blue"
-
Case 3 'status is green
-
Me!cboStatus = "Green"
-
End Select
-
-
-
Exit_Continue:
-
Exit Sub
-
-
Error_Routine:
-
MsgBox "Error# " & Err.Number & " " & Err.Description
-
Resume Exit_Continue
-
-
End Sub
That did the trick! I made one small adjustment: I changed the event procedure from 'GotFocus()' to 'Change()' as I want the AfterUpdate procedure to occur on a change to the date fields.
One more question, if I may: I want to lock the value in cboStatus following the AfterUpdate procedure. This is because I don't want someone to go back and change the status after a date change.
For each of your three cases above, I added a line of code following the Me!cboStatus = " " to read like this, for example:
Select Case Me.optGrpProject.Value
Case 1 'status changes to YELLOW
Me!cboStatus = "YELLOW"
Me!cboStatus.Locked
But when I execute the code I get the following Access error message:
Error #438: Object doesn't support this property or method.
I'm working in Access 2002. Is there another way to code the procedure to lock this field's value?
Thanks a bunch for your help!!
That did the trick! I made one small adjustment: I changed the event procedure from 'GotFocus()' to 'Change()' as I want the AfterUpdate procedure to occur on a change to the date fields.
One more question, if I may: I want to lock the value in cboStatus following the AfterUpdate procedure. This is because I don't want someone to go back and change the status after a date change.
For each of your three cases above, I added a line of code following the Me!cboStatus = " " to read like this, for example:
Select Case Me.optGrpProject.Value
Case 1 'status changes to YELLOW
Me!cboStatus = "YELLOW"
Me!cboStatus.Locked
But when I execute the code I get the following Access error message:
Error #438: Object doesn't support this property or method.
I'm working in Access 2002. Is there another way to code the procedure to lock this field's value?
Thanks a bunch for your help!!
Hmm....the combobox has a locked property, so the error is probably occuring the following reason:
You have a syntax error.
change: Me!cboStatus.Locked to: Me!cboStatus.Locked = True
Hmm....the combobox has a locked property, so the error is probably occuring the following reason:
You have a syntax error.
change: Me!cboStatus.Locked to: Me!cboStatus.Locked = True
Thanks! That worked, but I forgot to mention that I wanted the value locked only for the specific record where the date changed. In other words, if I have 10 records in my table but only 1 whose date changed, I want the cboStatus to be locked for the one record only. Is that possible?
Sorry for the omission. You've been extremely helpful!
- JM
Thanks! That worked, but I forgot to mention that I wanted the value locked only for the specific record where the date changed. In other words, if I have 10 records in my table but only 1 whose date changed, I want the cboStatus to be locked for the one record only. Is that possible?
Sorry for the omission. You've been extremely helpful!
- JM
Off the top of my head, I can't think of a way that you can lock just a control on a specifc record or subset of records ,,,,you would have to lock the entire record or records. If locking the entire record is not a problem, and the cboStatus combobox identifies the record or records to be locked, then you might be able to use Allen Browne's suggestion in the following link regarding the use of a textbox. http://www.thescripts.com/forum/thread215953.html
Let me know what happens.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bill Smith |
last post by:
The initial row is inserted with the colPartNum column containing a valid
LIKE pattern, such as (without the single quotes) 'AB%DE'.
I want to update the column value with the results of a query...
|
by: dixie |
last post by:
I have a form full of subforms which bring summary information onto the form
from about 12 different tables. I am trying to get all of that summary
information (mainly numbers) into 1 large table...
|
by: Maria Joao |
last post by:
I have two synchronized combo boxes and after the selection of the
desired record, I need the user to open the related report, by
pressing a button.
My problem is that a combo box doesn't update...
|
by: Arnold |
last post by:
Greetings Gurus,
In a mainform's header, I have a combobox named comboStudents. The
rowsource for this combobox is:
SELECT -999 As StudentID, "<Add New Student>" As FullName, "aaa" As...
|
by: keri |
last post by:
Hi,
I am struggling to learn access and VBA whilst creating a db, progress
is slow!
So far I have managed to run cascading combo boxes on a form by using a
sub in the after update procedure of...
|
by: sparks |
last post by:
I have a combo box that when you go to the next combo box it is
filtered based on the value in the previous one.
so if combo box 1 has fred as its value then combo box 2 has
1 2 3 for values....
|
by: tasmontique |
last post by:
Hello everyone,
I keep getting a syntax error in my update statement. The only thing that I notice is
that although the columns in my table have the same name as the fields on the form the...
|
by: Swinky |
last post by:
I am trying to make a combo box dependent on a text box. I cannot get
the combo box to pull the related data from the text box. I have been
all over this user group & have tried several versions...
|
by: injanib via AccessMonster.com |
last post by:
I have a combo box called "Recipient" who's row source is a table called
"Main" with three columns. The three columns are "Name", "Floor", "Location".
Following the combo box are two fields called...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
| |