|  | Select a name in combox box and then show today's date in a |  | |
| | | MacrossHunter77 via Acces |  |
| Posted: Tue Sep 16, 2008 8:36 pm Post subject: Select a name in combox box and then show today's date in a |  |
| |  | |
Hello there I kind of new of this so this is my problem my boss want's me to modify his access program so he is saying that everytime he changes the status in the combo box it automacally will generate today's date in another box is like a update date just to be sure when the record was modifies well here is what I trying to explain to you guys:
there is a combo box Name Status with 4 types of status "In Progress", "Delivered", "Resubmitted", Void",and the combox properties he has in the Data tab select a "value list" this is so you can add a new status name like void redone etc" well then he has 4 text boxes name with the same that you select with the status combo box you know one text box is "In Progress" the second is name "Delivered" etc etc well he wants that everytime he pick a status the date automatically appear in their respectively box for example if I choose "Delivered" in the combox box then on of the text box that say "Delivered" will show today's date because that is why you make the change then I change it to "Void" then then date will show in the Void text box but remenber the other text box that says "Delivered" must not change the date still have the date that was last updated please anybody help me I would appreciate thanks to all
-- Message posted via AccessMonster.com LINK |
| |
| | | Klatuu |  |
| Posted: Wed Sep 17, 2008 12:53 pm Post subject: Re: Select a name in combox box and then show today's date i |  |
| |  | |
If, as you state, the name of the text boxes to be updated are the same as the values in the combo, then you can use the combo box's After Update event to put the date in the appropriate box:
Private Sub Status_AfterUpdate()
if ControlExists(Me, Me.Status) Then Me.Controls(me.Status) = Date End If
End Sub
******************
Public Function ControlExists(frm As Form, strCtlName As String) As Boolean Dim ctls As Controls Dim ctl As Control
Set ctls = frm.Controls
For Each ctl In ctls If ctl.Name = strCtlName Then ControlExists = True Exit For End If Next ctl
End Function
This is how it works. Me.Controls() is a reference to the controls collection of the current form. To refer to a specific item in the collection, you can use either its ordinal position or its name, so if the Status checkbox on the current form is Delivered, the control named Delivered will be populated with the current date.
The ControlExists function is necessary because your boss wants to be able to add new status codes. The problem here because there will be no text box named for the control and if you don't test to see if it exists, you will get an error if you try to assign a value to a control that does not exist.
"MacrossHunter77 via AccessMonster.com" <u38734@uwe> wrote in message news:8a4c6d18acae2@uwe...
| Quote: | Hello there I kind of new of this so this is my problem my boss want's me to modify his access program so he is saying that everytime he changes the status in the combo box it automacally will generate today's date in another box is like a update date just to be sure when the record was modifies well here is what I trying to explain to you guys:
there is a combo box Name Status with 4 types of status "In Progress", "Delivered", "Resubmitted", Void",and the combox properties he has in the Data tab select a "value list" this is so you can add a new status name like void redone etc" well then he has 4 text boxes name with the same that you select with the status combo box you know one text box is "In Progress" the second is name "Delivered" etc etc well he wants that everytime he pick a status the date automatically appear in their respectively box for example if I choose "Delivered" in the combox box then on of the text box that say "Delivered" will show today's date because that is why you make the change then I change it to "Void" then then date will show in the Void text box but remenber the other text box that says "Delivered" must not change the date still have the date that was last updated please anybody help me I would appreciate thanks to all
-- Message posted via AccessMonster.com LINK
|
|
| |
|
|