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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double click on text box to unlock??

Status
Not open for further replies.

bluedollar

Programmer
Jul 24, 2003
174
GB
I have a text box that is locked, I want the user to be able to double click on the text box to be able to unlock the text box and change the value.

The code thatI am using for this is:

Private Sub price_DblClick(Cancel As Integer)
Me![Price].Enabled = True
Me![Price].Locked = False
End Sub

I have also treid using a command button to acheive this, however when the user double clicks on the text box or command button, the text box remains locked.

Any help would be greatly appreciated.

Thanks

Dan
 
Hi,

I notice in your code that you have enabled = true, does that mean that you have set enabled to false? if so then the double click event wont be triggered because the control isnt enabled. Enable the control (leave it locked) and you will find that the double click event can be triggered (if you want to be sure an event is triggering and not just your code at fault use a break point or add a line with 'Stop' in your code)...

HTH, Jamie
FAQ219-2884
[deejay]
 
If you want it to appear disabled, just change the background colours, then change them back when you "enable" it.

Ben

----------------------------------------------
Ben O'Hara "Where are all the stupid people from...
...And how'd they get so dumb?"
rockband.gif
NoFX-The Decline
----------------------------------------------
 
The text box values are now set to:

enabled = true
locked = true

and the code is set to:

Private Sub price_DblClick(Cancel As Integer)
Me![Price].Locked = False
End Sub

But it still does not work, the text box is on a subform, would this affect the outcome of the code?

Thanks

Dan
 
I also put a msgbox "event triggered" in the code and the code is being triggered??
 
Hi Dan, those settings should be okay, the code's okay and being a sub-form control should make no odds.

Is the subform based upon a query of more than 1 table? in order for the query to be updateable you need to include the joining key fields from all of the tables (you can hide them in the form but they need to be included in the SELECT statement)

HTH, Jamie
FAQ219-2884
[deejay]
 
hmmmmmmmmmmmmmmmmmmmmmm,

you might try "refresh". some control propreties seem (to me) to not take effect until forms are refreshed, and this doesn't occur on the property change itself.

you might also want to consider 're-locking' the control after the edit is complete, although this can be tricky with the focus doing some odd things in these property setting processes. you certainly want to set up SOME mechanisim to control the locking, as simply setting it will leave the setting for perpetuity w/o additional action. at some point you will also need to deal with the issue of saving changes to the FORM, as Ms. A. is a bit jealous and will ask if you want to save them (closing the form?). Altogether, I would generally avoid this approach, perhaps using an INPUT box on the double click to get a new value and programatically place it in the control / field.



MichaelRed
mlred@verizon.net

 
Thanks

Got it working, I just took the text field off the subform and onto the main form (it did not really need to be on the subform anyway).

Now it works fine

Thanks again, for the help

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top