|
-
Apr 4th, 2005, 03:17 AM
#1
Thread Starter
Hyperactive Member
editing comboboxes
i want the user to only b able to edit after clicking the edit button, so I created a form_keypress sub and if a boolean inEDit is not true then keyAscii is = 0!! it all works fine.
However I hav alot of comboboxes on the page and at present the user is able to edit the selection!!! how can i write a sub that does the same as form_keypress ie if the user does not click the edit button then the selection of the combobox will not change??
Thanks in advance
Last edited by pame1la; Apr 7th, 2005 at 03:53 AM.
-
Apr 4th, 2005, 03:24 AM
#2
Re: editing comboboxes
Set it to type 2 so that they can't edit it. When they click on it, use a textbox with the value of the combobox. When they press enter, re-write the comboxbox with the updated item. You could even float the textbox ofer the combobox item to have it appear that they are editing the item. I do this with a flexgrid, and the cell appears to change color as I edit it.
-
Apr 4th, 2005, 06:39 AM
#3
Re: editing comboboxes
David has a good suggestion, and to take that one step further (if you have the need to do so), you could even lock the textboxes so they can be touched until such time as the Edit button is clicked. Then, you can loop through the textboxes and unlock them.
-
Apr 5th, 2005, 10:59 AM
#4
Thread Starter
Hyperactive Member
Re: editing comboboxes
 Originally Posted by dglienna
Set it to type 2 so that they can't edit it. When they click on it, use a textbox with the value of the combobox. When they press enter, re-write the comboxbox with the updated item. You could even float the textbox ofer the combobox item to have it appear that they are editing the item. I do this with a flexgrid, and the cell appears to change color as I edit it.
what do you mean by set it to type 2????
-
Apr 5th, 2005, 11:06 AM
#5
Re: editing comboboxes
On the property page for the combobox, scroll down to Style, and select Style 2 - Dropdown List
-
Apr 6th, 2005, 03:13 AM
#6
Thread Starter
Hyperactive Member
Re: editing comboboxes
isn't it easier way to do it... like for the textboxes i have a key-press sub that sets keyascii= 0 if not in edit.....
is there not sum sort of sub i can write which will make all mouse clicking invalid until it is in edit??????
-
Apr 6th, 2005, 06:11 AM
#7
Re: editing comboboxes
 Originally Posted by pame1la
isn't it easier way to do it... like for the textboxes i have a key-press sub that sets keyascii= 0 if not in edit.....
Sure. You could use a Boolean that the edit button sets to True. However, this would mean putting
VB Code:
If blnCanEdit = False Then
KeyAscii = 0
End If
in every keypress event of every text box you have.
 Originally Posted by pame1la
is there not sum sort of sub i can write which will make all mouse clicking invalid until it is in edit??????
First, you don't want to make all mousing clicking invalid. If you did that no one could click the Edit button to making editing OK.
If you simply set the Locked property of your textboxes to True, in design, then you could unlock them all by calling a sub from your Edit button that iterates through all your textboxes and unlocks them.
-
Apr 6th, 2005, 06:19 AM
#8
Thread Starter
Hyperactive Member
Re: editing comboboxes
[QUOTE=Hack]Sure. You could use a Boolean that the edit button sets to True. However, this would mean putting
VB Code:
If blnCanEdit = False Then
KeyAscii = 0
End If
NO I HAVE THAT IN FORM_KEYPRESS SUB.... cant i do sumfing when the user clicks on cmboboxes?? eg. if bInCanEdit = False then cbo1.Locked = True....
but that would be quite long isn't there anything lik form_mouseclick
-
Apr 6th, 2005, 06:36 AM
#9
Re: editing comboboxes
[QUOTE=pame1la]
 Originally Posted by Hack
Sure. You could use a Boolean that the edit button sets to True. However, this would mean putting
VB Code:
If blnCanEdit = False Then
KeyAscii = 0
End If
NO I HAVE THAT IN FORM_KEYPRESS SUB.... cant i do sumfing when the user clicks on cmboboxes?? eg. if bInCanEdit = False then cbo1.Locked = True....
but that would be quite long isn't there anything lik form_mouseclick
There is a Form_Click() event. You can toggle the Locked property with this.
VB Code:
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As ComboBox
For Each cCombo In Me.Controls
cCombo.Locked = pblnIsLocked
Next
End Sub
'to turn on editing
LockCombos False
'to turn off editing
LockCombos True
-
Apr 6th, 2005, 07:39 AM
#10
Thread Starter
Hyperactive Member
Re: editing comboboxes
 Originally Posted by Hack
There is a Form_Click() event. You can toggle the Locked property with this.
VB Code:
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As ComboBox
For Each cCombo In Me.Controls
cCombo.Locked = pblnIsLocked
Next
End Sub
'to turn on editing
LockCombos False
'to turn off editing
LockCombos True
It doesnt seem to be doing anything!!! wot i have done is added the above sub and then have wrote LockCombos (True) but it hasnt worked!!!
-
Apr 6th, 2005, 08:43 AM
#11
Re: editing comboboxes
Try to find out if the combobox ia actually being locked...
VB Code:
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As ComboBox
For Each cCombo In Me.Controls
cCombo.Locked = pblnIsLocked
msgbox cCombo.Locked
Next
End Sub
-
Apr 6th, 2005, 08:54 AM
#12
Re: editing comboboxes
 Originally Posted by pame1la
It doesnt seem to be doing anything!!! wot i have done is added the above sub and then have wrote LockCombos (True) but it hasnt worked!!!
Don't use parenthese. Just say either:
LockCombos False
'or
LockCombos True
-
Apr 6th, 2005, 09:00 AM
#13
Re: editing comboboxes
Maybe she used Call LockCombos(True)
-
Apr 6th, 2005, 09:04 AM
#14
Thread Starter
Hyperactive Member
Re: editing comboboxes
 Originally Posted by dee-u
Maybe she used Call LockCombos(True) 
naaa dont wry i didnt
-
Apr 6th, 2005, 09:19 AM
#15
Re: editing comboboxes
 Originally Posted by dee-u
Maybe she used Call LockCombos(True) 
She could do that if she wished.
 Originally Posted by pame1la
naaa dont wry i didnt 
Did it work without the parentheses?
-
Apr 6th, 2005, 09:21 AM
#16
Re: editing comboboxes
Call LockCombos(True) and LockCombos True would just be the same....
-
Apr 6th, 2005, 09:27 AM
#17
Thread Starter
Hyperactive Member
Re: editing comboboxes
no its still not wrking!!!
have i understood right: i add the sub
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As ComboBox
For Each cCombo In Me.Controls
cCombo.Locked = pblnIsLocked
Next
End Sub
in ma code...and after the search option i have added LockCombos True because i want the user not to be able to edit the cmboboxes, den wen they click edit i have LockCombos False......
-
Apr 6th, 2005, 09:32 AM
#18
Re: editing comboboxes
Try to determine if your ComBox is actually being locked in that LockCombos procedure.
Or perhaps you could post the code where you said it is not working, maybe it is being locked then 'accidentally' unlocked them again....
-
Apr 6th, 2005, 09:35 AM
#19
Thread Starter
Hyperactive Member
Re: editing comboboxes
theres sumthing wrong with the loop cos it only goes through it 1ce!!!!
-
Apr 6th, 2005, 09:36 AM
#20
Re: editing comboboxes
 Originally Posted by pame1la
no its still not wrking!!!
have i understood right: i add the sub
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As ComboBox
For Each cCombo In Me.Controls
cCombo.Locked = pblnIsLocked
Next
End Sub
in ma code...and after the search option i have added LockCombos True because i want the user not to be able to edit the cmboboxes, den wen they click edit i have LockCombos False......
If I'm understanding what you want to do correctly, you should add LockCombos True in the Form_Load event.
Then in the click event of your Edit button add LockCombos False.
Try this...before hitting your Edit button, after the form loads, try to do stuff with the combos. You should not be able to.
-
Apr 6th, 2005, 10:03 AM
#21
Thread Starter
Hyperactive Member
Re: editing comboboxes
no it still doesnt wrk!!! it doesnt loop through ths sub rite, it sod do it for each combo box rite, eg if i hav 5 comboboxes on the form it should go through the loop 5 times rite????
it only does 1ce!!!!!!
-
Apr 6th, 2005, 10:07 AM
#22
Re: editing comboboxes
 Originally Posted by pame1la
no it still doesnt wrk!!! it doesnt loop through ths sub rite, it sod do it for each combo box rite, eg if i hav 5 comboboxes on the form it should go through the loop 5 times rite????
it only does 1ce!!!!!!
Could you attach your form?
I just put 5 combo boxes on a test form, ran that sub and locked and unlocked them at will, so I really need to see what you are doing.
-
Apr 6th, 2005, 10:17 AM
#23
Thread Starter
Hyperactive Member
Re: editing comboboxes
heres an example:
Private Sub Combo1_Click()
txtbox.Text = Combo1.Text
End Sub
Private Sub Command1_Click()
LockCombos False
End Sub
Sub Form_Load()
LockCombos True
End Sub
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As ComboBox
For Each cCombo In Me.Controls
cCombo.Locked = pblnIsLocked
Next
StatusBar.Panels(1) = "Press Edit button before editing record"
End Sub
-
Apr 6th, 2005, 10:29 AM
#24
Re: editing comboboxes
You are right Pamela. I took your code, made a form with 5 combos and now I know what you are talking about. Replace the LockCombos sub with this
VB Code:
Private Sub LockCombos(pblnIsLocked As Boolean)
On Error Resume Next
Dim cCombo As Control
For Each cCombo In Me.Controls
If TypeOf cCombo Is ComboBox Then
cCombo.Locked = pblnIsLocked
End If
Next
End Sub
It should now work like a champ. Let me know.
-
Apr 6th, 2005, 10:40 AM
#25
Thread Starter
Hyperactive Member
Re: editing comboboxes
thanks hack it works with the practice thing, now im gona add to my propa question!!!
can i ask another question.... i have 1 combobox, and when the user edits the combobox a column in a grid is recalculated.... i want it to recalculate that column for ALL rows and not just the row in edit mode....eny ideas????
-
Apr 7th, 2005, 03:53 AM
#26
Thread Starter
Hyperactive Member
Re: editing comboboxes
If the comboboxes are locked, i want to add a message on teh status bar, how could i do that????
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|