textbox double click

saleemMSMS

Registered User.
Local time
Today, 12:13
Joined
Aug 12, 2009
Messages
92
hi
i have 10-20 text boxes in a form
all these text boxes should do the following if double clicked
Me.AllowEdits = True

but its a long process to write this code to each and every text boxes double click event. insted of doing that, isn't there any other way to write it only once and pass the text box name ?? (or something like that ?)
please reply.
thanx
 
However you do this, you will need to put code in the Double click event of each Text Box. I can't think of any short cut for avoiding this.
 
as long as you dont want to do anything else with the event, you can just have a generic function, and do it without coding each event

note this is aircode, but it should be ok - you just need some syntax to deal with a control, rather than the form.

function toggle
with screen.activecontrol
allowedits=not allowedits
end with
end function


then for each control you want to do this, just set the event handler to be as follows - note you MUST have the brackets and the = sign - but then access looks for a function, rather than an event handler

=toggle()

note that this function can be in a code module, and therefore avaialble to any form, or just in your forms module.

you can pass an argument in the parameters - this is how the inbuilt switchboard form handles the buttonclicks - the event function for each buttonclick is just

=handlebuttonclick(n) (where n is the button number)


you can also use this sort of idea with gotfocus/lostfocus events to highlight the control that has the focus.
 
Last edited:
Just to add to Dave's solution you will still have to go to the Double-Click Event of each text box and enter Call Toggle(). In a way this is defeating the object of the exercise. However there is less coding. The way that Dave's has suggested the allow edits flag is reset to the opposite of what the current status is. So the first double-click allows edits, the second double click disables edits.

David
 
Just to add to Dave's solution you will still have to go to the Double-Click Event of each text box and enter Call Toggle(). In a way this is defeating the object of the exercise. However there is less coding. The way that Dave's has suggested the allow edits flag is reset to the opposite of what the current status is. So the first double-click allows edits, the second double click disables edits.

David

david - no, you dont need ANY event handlers ... as long as the entry in the forms control property has an equals sign then putting

=myfunc() as the property calls a function called myfunc with no further action. You just need one function myfunc for the WHOLE of the app.
 
Dave,

So I've just created a simple function in a module that is as follows

Public Function Msg()
Msgbox "Hello"
End Function


So where are the forms control Property?

David
 

Users who are viewing this thread

Back
Top Bottom