Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change combo box to text box and then lock 3

Status
Not open for further replies.

yont11

IS-IT--Management
Apr 13, 2006
19
AU
I am working on a workflow for a project. I want to run code from say an exit or lost focus event on a combo box.
The combo box allows you to choose the milestone that the project is up to. When the milestone is chosen and the user leaves the combo box I want code to run and change the combo box to a text box and also lock the record so it can't be changed. Could someone help me with the code to achieve this. Thanks.
 
You can get the changing effect by having a combobox and a textbox overlaying each other. Both have the same recordsource, but the textbox is locked. Only one is visble at a time. If this is a continous form it will be much harder to do than if it is a single record form. But I would have a boolean field "blnLocked". On the combo boxes after update event set focus to the textbox and make it visible , make the combobox invisible, and set the value of blnLocked to true.
On the on current event of the form check the value of blnlocked. If blnlocked is true make the textbox visible hide the combo, else make the combo visible hide the textbox.
 
Yes, what MajP said, is very feasible.
I'm just wondering, what dictates having the combo visible?
As long as Textbox has a value?

Maybe on OnCurrent, as MajP said,

cboMilestone.Visible = IsNull(txtMilestone)
or
Reduce size of combo, so just arrow is visible.
Place it aside the textbox and,

cboMilestone.Enabled = IsNull(txtMilestone)
or
cboMilestone.Locked = Not IsNull(txtMilestone)

...for example.

BTW It sounds like a person gets only one chance,
to make a selection from combo.
What's the criteria?
 
More information for Zion7 & MajP. The reason for the combo box is to limit the choice of milestones that can be selected (i.e there are only certain choices)The work flow is part of a professional services business where there are certain stages that need to be completed in a client matter, sometimes there is a need to go backwards if more information is requested therefore you may have the same milestone twice in the workflow, the thing that would differentiate them would be the date the milestone was achieved.The idea I am getting at is to have a chronological order of events. It wold be a single page on a form where the client matter was selected and there would be say 10 combo boxes to select the milestone one after the other. When a milestone is logged I want that milestone locked and dated. When they next come back to update the matter they would use the next combo box to select the next milstone. Hope this makes sense, its a bit hard to explain. Very much appreciate the help. Cheers.
 
If You have a continuous form, which seems likely with normalisation, you could use Conditional Formatting and set an Expression for the Milestone combo:
[tt]Not IsNull([Date1])[/tt]
and then choose Enabled from the conditional formatting options.

If this is a single form:
Code:
Private Sub Form_Current()
    Me.Milestone1.Enabled = IsNull(Me.Date1)
End Sub

Private Sub Milestone1_AfterUpdate()
If MsgBox("Achieved?", vbYesNo) = vbYes Then
    Me.Date1.SetFocus
    Me.Date1 = Date
    'Some other control
    Me.Milestone1.Enabled = IsNull(Me.Date1)
End If
End Sub
May suit, but you may need to look at your table design.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top