Click Event In Control Array
Hey there,
I created an image control array (at design time) and associated a different picture for each one to create a custom toolbox, like this:
image1(0) image1(1) image1(2) . . .
Well, when I double-click over any image object to codify the click event, it goes to the code and shows Private Sub Image1_Click(). When I try to run the program, the compiler show the "Procedure declaration does not match description of event or procedure having the same name" error.
I know that it occurs because I have an array but the click event is referring to the images at generic way. What I don't know is how to solve that.
Any clues?
Thanks!
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Capture Click Event Of Control Array Combobox
I have a control array combobox named PoolCombo. I am trying to capture the click event on any of the loaded ComboBoxes with:
Private Sub PoolCombo_Click(Index as Integer)
MsgBox "Got it"
End Sub
This does not seem to work, is this possible or (more likely) I am not coding it correctly. Thanks!
Why Is A Control Array Cmb Box Click Event Being Executed..... **RESOLVED **
In my application, I have 2 forms (Main Menu and New Items).
On the New Items form I dynamically build a control array of combo boxes.
When I click the New Items command button on the Main Menu, the cmb_action(0) click event gets fired after the form_load event. Why???
I only want the click event to occur once the control array has been populated and the user clicks on the control.
Thanks.
Label Array Click Event
Feel stupid asking...but if you have a click event for an array of labels, how do you know which one is clicked? I thought I thought I could figure it out easily, but I can't get it to work. I tried using both an If statement and a select case. Personally I'm more accustomed to using If statements, so I'll use that as example.
PFace is name of label array, obviously.
I tried:
<pre>Private Sub PFace_Click(Index As Integer)
If PFace.count = 0 Then
'do what ever
End If
End Sub</pre>
But, This doesn't do anything when the label is clicked.
And It gave me an error with <font color=blue>if pface.item = 0</font color=blue> and <font color=blue>if pface.index = 0</font color=blue>.
So <font color=blue>If Pface(0) then</font color=blue> was my next guess, which was always true, and therefore didn't work (this works with command buttons btw, which is what I did it with originally then tried to also allow this to work, and promptly sent my ego plumeting into oblivion =p).
Resolved - Cmd Button Array Click Event
Hi
If I have 4 cmd buts. in an array...and I want to use one of the
buttons click events how would I accomplish this....
my cmd button array is
cmdbutton_shift
Thanks
One Sub/function To Handle The Click Event To All The Com.but.s Of A Com.but. Array??
I'm making an interface where the user can add (run time) as many com.but.s as he wants in a form.
Is it possible to create one Sub CommandButton(i)_Click (for ex.) for all the objects of the arraythat will provide the same reaction but each time it will take the 'number' of the com.but. clicked and do something only to it?
My problem is that the number of the cbs is unknown before run time and I want somehow to provide reaction to all the control array's objects.
Thanks in advance
dkons
Raising The ActiveX Control's Event On The Click Of The ActiveX C Ontrol's Sub Form Buttton Click
Hi Friends,
I am designing one ActiveX Control with a lot of sub forms which r shown on
calling the methods or from some other events.
I want to raise few event of this ActiveX Control on the click of any button
of ActiveX control's sub form.
I want to give the user of the activex control some development control
with the help of these events.
I am not able to access the events (defined in the user control at design
time) of the activex control from the sub form of the activeX control.
Can anybody tell me how to do that.
Thnx in advance,
Naveen !!!!!
Raising The ActiveX Control's Event On The Click Of The ActiveX C Ontrol's Sub Form Buttton Click
Hi Friends,
I am designing one ActiveX Control with a lot of forms which r shown on
calling the methods or from some other events.
I want to raise few event of this ActiveX Control on the click of any button
of ActiveX control's sub form.
I want to give the user of the activex control some development controls
with the help of these events.
I am not able to access the event (defined in the user control at design
time) of the activex control from the form.
Can anybody tell me how to do that.
Thnkx in advance,
Naveen !!!!!
Image Control Click Event
i am using VB .NET
I have an image control which contains a .ico file. (in a .aspx page)
on the click event of this control(in .aspx.vb page), i want to show another page, which is a web link.
how do i do it?
Referencing A Control On The Click Event
I have numerous labels in a project. when i click on one of the labels i want to change the backstyle of all the labels in the form except the one i clicked on. i was able to use "for each ctrl in controls... next ctrl" function to change all of the labels, but could not identify which label was clicked. I don't want to "hard-code" the label since i would have to do this for each labels click event. any suggestions?
Help With User Control And Click Event
Hey everyone, I got a user control, not created by me, and the problem is the author of the control never really finished it, it looks as if he kinda just quickly put it together. I need to have a click event on the user control but dont quite understand how it works.
Here is an example of how the author used the KeyDown event:
VB Code:
Public Event KeyDown(KeyCode As Integer, Shift As Integer) Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)' all keydown coding here...doesnt really matterEnd Sub
The thing is, there is no where through the rest of the code that triggers the KeyDown event...is this an event that vb will automatically trigger? And if so, it shouldnt be hard to make a click event..
So any suggestions on what I should do to make a click event for the user control? Thanx everyone for the help.
***Resolved*** Control's Click Event.
Hi,
Here's the question.
If I have the control's name stored in a string, can I call it's click event?
I don't want to iterate through the controls on the form and compare the names.
Is there an api call? SendMessage?
Click Event And Timer Control
Hello to all:
Being a novice at Visual Basic, I am trying to create a private sub that
will repeat or loop every 10 seconds that starts when a "Start" button is
clicked and stops when a "Stop" button is clicked. I am not sure if I need
to incorporate some kind of loop routine or can I use a timer control?
Any help would be appreciated.
Thanks,
Ken
Click Event In PictureBox Control
Hi,
I want to utilize click event on PictureBox Control. The name of the PictureBox in my code is Display1. The following is the function triggered by Click Event.
Private Sub Display1_Click()
MsgBox "Reached Here"
End Sub
This works fine. But when I open a avi in this PictureBox using mcisendstring, the function is not reached on clicking the PictureBox. What is the reason.
Thanks in advance.
[VB] Click Event On WebBrowser Control
Hello all I am using the webBrowser control on an vb 6 form and want to have a click event... basically if they click on the WebBrowser1 control it will bring the same page up in a real web browser.
regards,
Jay
How To Cancel The Click Event In The Image Control
I inserted image control (to make it a background for some controls) on the sheet and then I placed some controls like command after I made the image "send backward" and controls "send forward" . When I run the project the controls appear on the image. But when I click on the image the controls disappear and then appear again when I move the mouse away from the image. How to fix this problem. By the way I tried to make the propert of image, Enable= false, But it didn't success .
thank you for help.
Trying To Get A Control To Fire A Double Click Event
I have taken over the development of a control that has a MaskEdBox and a button on a user control.
On my application form I am trying to get the control to fire an event when I double click the MaskEdBox element of the control (to populate it with "todays" date). The trouble is that the MaskEdBox doesn't have a double click event to expose. I tried to use the usercontrol's dblclick event for this but, naturally, nothing happens. Is there a way of getting the MaskEdbox to inherit the event from the user control?
Does anyone have any ideas.
Handling Click Event Of Shockwave Control
I am a beginner in VB. I want to use shockwave control in VB6. But the control does not have any event like click event associated with it. I want to handle it. If anyone can help me.
Thanks in advance. Any help will be appreciated.
Click Event Not Firing From User Control
OK...I was messing around with trying to make a simple card game type program, more for fun than anything. I created a single form and a user control of type Card. I implemented manual drag and drop...and this works fine, but I'm not getting the click event to fire...any direction you could give would be appreciated.
here's the code for the main form:
VB Code:
Option Explicit Dim OffsetX As IntegerDim OffsetY As IntegerPrivate Sub aCard_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) aCard(Index).Drag vbEndDragEnd Sub Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single) Source.Move X - OffsetX, Y - OffsetYEnd SubPrivate Sub aCard_Click(Index As Integer) MsgBox "We Clicked!!"End Sub Private Sub aCard_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single) 'Test OffsetX = X OffsetY = Y aCard(Index).Drag vbBeginDragEnd SubPrivate Sub Form_Unload(Cancel As Integer) Dim i As Integer For i = Forms.Count - 1 To 0 Step -1 Unload Forms(i) NextEnd Sub Private Sub mnu_FileExit_Click() Unload MeEnd Sub
Here's the user control:
VB Code:
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Public Event Click()Private Sub UserControl_Click() RaiseEvent ClickEnd Sub Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) RaiseEvent MouseDown(Button, Shift, X, Y)End Sub Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) RaiseEvent MouseUp(Button, Shift, X, Y)End Sub
Image Control Mouse Click Event?
HIiiii
I am trying to use Image Control MouseDown and MouseUp event. It is responding for right mouse click. But not for left mouse click. Even it is not responding for Click and Double_Click event too.
What could be problem?
Hdave
Adding Click Event To Custom Control
I have a custom control that I purchased that does not have a click event. I have contacted the developer and am waiting a response. Is there a way that I can add a click event? maybe manipulate the forms click event some how? All it has is GotFocus, LostFocus, DragDrop, DragOver, and Validate events. Is the a mouse object that I can declare, something, anything??
Thanks,
Is It Possible To Disable The Double Click Event Of A Control?
I'd like the user to be able to click very quickly on a variey of controls (like labels etc) and catch the mouse up and down events (or click).
BUT, if the user clicks too quickly the double click event fires, skips the mouse down and then processors the mouse up!
so clicking 5 times very quickly on a label produces
DOWN->UP->DOUBLECLICK->UP->DOWN->UP->DOUBLECLICK->UP->DOWN->UP
instead of ....
DOWN->UP->DOWN->UP->DOWN->UP->DOWN->UP->DOWN->UP->
is there a way to kill the double click event?
Cheers?
How Can I Dynamically Call An Event (e.g. Click) For A Control ?
I dynamically created a from with about 90 controls in it. To access the controls I use a simple loop like this:
Dim el As Control
For Each el In UserForm1.Controls
If left$(el.Name,3) = "cmd" Then
REM Code to access standard events of the control
End If
Next el
How can i acces e.g. a Click-Event? Here i cannot write cmdButton1_Click.
The control is stored in the variable el. But (of cause) el.Name_Click doesn't work.
This isn't trivial, isn't it ????
How To Kill A Double-click Event For A WMP Control
When the user double-clicks on a WMP control then the currently playing video changes to fullscreen mode. This seems to be a default behavior of the windows media control itself which I can not figure out how to turn off. As a result, is there a way to receive the double-click event for the WMP control but not allow the OS to process it ? Basically, in the myWMP1_DoubleClick event, can I somehow not allow the functioning to continue through the OS (ie: kill the event somehow?)
Edited by - uncletr on 9/27/2004 5:10:27 PM
Image Control Click Event Not Occuring?!
Hi All,
I am getting some strange behaviour with an image object.
I have some code that I run when the user clicks on an Image object but if you click quite fast... about ... I was just starting to write 'about as fast as a double-click' when it suddenly occurred to me what the problem is here!
I'll finish anyway because it might be instructive to someone else...
If you click too fast the program doesn't respond on some of the clicks (you sometimes need to click the same image up to 4 times).
As I was explaining this above I realised that the double-click event was probably being fired!... I just tested it and that is what's happening!
So now all I do is pass the event and it's index on to the standard click event and all is well!Code:Private Sub imgResponse_DblClick(Index As Integer)
imgResponse_Click Index
End Sub
Anyway, sorry for wasting your time but I thought it was quite amusing...
Mac
Double-click Event Firing Off Click Event Code?
For example:
In a listbox, I have a click event that changes a label's caption from 'Loaded' to 'Clicked' and changes the color from black to red.
I have a double-click event that shows a message box saying "I've been double-clicked."
You can re-set the label by clicking it.
When I click the listbox, the label's caption and color changes. This is what I expected.
When I double-click the listbox, the label's caption and color changes, and the message box is displayed. Why?????
Simple Error {Click Event For Image Control}
hi guys,
I have this form and I want to check if the user has clicked on a image by means of a buttons. The following is my code.
-------------------------------------------------------
Private Flag As Boolean
Private Sub Command1_Click()
If Flag = True Then
MsgBox "True" else
MsgBox "False"
End If
End Sub
Private Sub Image2_Click(Index As Integer)
If Image2(Index) = 1 Then
Flag = True
Else
Flag = False
End If
End
------------------------------------------------
Can anyone check out my mistake please
Detecting The Mouse Click Event With A Combo Box Control
Does anyone know if there is a mouse click event fired when a combo box dropdown is clicked. The click event seems to fire only when something is selected from the dropdowm list. But if nothing is selected the event appears not to happen.
I need a way to detect the click event even if nothing is selected or no changes are made to the selection.
Can anyone help?
Click Event Control Problem ...code Included!
the following code is from msdn example, however the private declaration that I put on top of the module gives problems...only possible (or something) in object module it says...
The intention is to create a menubar...that is not a problem so far...:-)...and when a user clicks on a controlbutton it has to detect wich control so that I can call a function and give a string with it...the string depends on wich control is pushed...
Code:
Private WithEvents ce As CommandBarEvents
Sub Test()
Dim c As CommandBarControl
Set c = Application.VBE.CommandBars("Tools").Controls(1)
Set ce = Application.VBE.Events.CommandBarEvents(c)
End Sub
Private Sub ce_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)
' Put event-handling code here
End Sub
Question 1 : The problem with the private declaration...how to solve? what do i do wrong?
2 : Do I have to create this msdn example for all the controls in the menu or just one time and the control pushed is recognised?
An answer on this question solves all...Can I give the on Action for a control a funtion with an argument?????????????????????????? How to do this?
nitro...all help is welcome
Image Click Event Stops Imagelist Control From Updating
Using Excel VBA
I cannot work out why the following is happening:
I have a form that is populated from the contents of a spreadsheet, with each row being read using a For Next Loop.
In addition to the form containing textboxes, buttons and labels it also has an imagelist control.
A mousemove event is linked to the image and this functions correctly (displays a form with an imagelist control and linked image). If I change the image event to anything else e.g. mousedown, click, doubleclick etc and run the same code as a result of this event I get a situation whereby the next line that is read from the spreadsheet updates the textboxes and labels but not the image (imagelist linked), the picture remains at the previous image. However If I click the image it displays the correct larger picture and when that form is closed the imagelist on the main form is updated correctly.
It appears that the image click procedure is stopping the variables being updated for the imagelist control until the sub form has been closed, yet using the same code I get no problems with mousemove event.
An example of the code is as follows:
Code:
For counter = 7 To 27
Image1.Picture = ImageList1.ListImages(counter - 6).Picture
pic_label1.Caption = Worksheets("Sheet2").Cells(counter, 4) & " - " & Worksheets("Sheet2").Cells(counter, 5)
.........
Next
'Private Sub Image1_Click() ---------------------------------------- code causes imagelist control to stop updated
'image2show = counter - 6
'imageshow.Caption = Worksheets("Sheet2").Cells(counter, 4) & " - " & Worksheets("Sheet2").Cells(counter, 5)
'imageshow.Show
'End Sub
----------- code works ok
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
image2show = counter - 6
imageshow.Caption = Worksheets("Sheet2").Cells(counter, 4) & " - " & Worksheets("Sheet2").Cells(counter, 5)
imageshow.Show
End Sub
Private Sub UserForm_Activate()
Me.Caption = Worksheets("Sheet2").Cells(image2show + 6, 4) & " - " & Worksheets("Sheet2").Cells(image2show + 6, 5)
image2.Picture = ImageList2.ListImages(image2show).Picture
End Sub
How To Detect A Click Event On Embeded Image Inside An Activex Control.
Hello All,
I need some help figuring this out. I am developing an ActiveX control that contain an array of multiple image boxes embedded inside a windowless transparent form (container). Based on property settings at design time, only one imagebox is visible, and all others are set to be invisible. I have a method (property) set in the control that decides which image is going to be visible. This is settable during a standard VB exe project development, and at run time via user selction. When I compile the OCX and use it to on a standard VB EXE project, I don't have an option available to write code for an Image click event. Only events available are control got focus, & lost focus etc. How do I go about adding the Image click event (to the Visible Image) inside my control?
Do I have to implement another method/event within my Activex control? If I did that, how would I then pass the name of the caller (name of the form where the control click was initiated) in to my activex event, and have the activex report back to the "SAME" calling form during run time?
Thanks
KeyPress Event For A Control Array
I have an array of comboboxes(0 - 3) which have about 7 items in them. When a user decided's not to use the mouse, and starts to type in them, I would like the combobox to automatically jump to the associated listindex(by comparing the first letter perhaps). At other points in my code I retrieve info from these comboboxes using the listindex, and It's crashing when someone decides to type. Any Idea of how to code this??
How Can I Resolve Rt-Click In MSflexGrid Control Array
Hi,
I have a control array of MSFlexGrid1's and I would like to right click on one of them and take an action.
My test code below causes a compile error: "Proceedure Declaration does not match description of event or proceedure having the same name"
I have nothing with the same name.
Private Sub MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
Debug.Print "right clicked"
End If
End Sub
I have nothing with the same name. Is the control array messing me up? How can I resolve the issue.
Thanks Robo
Event For Textbox Control Array At Run Time
Hello all,
I am wondering if there is a way to get the event to work for text box control array at run time.
Here is what I have.
Code:
Dim ctrltxt(1 To 100) As VB.TextBox
For x = 1 to 100
Set ctrltxt(X) = Controls.add("vb.textbox", "ctrltxt" & Right(Str(X), 1), ctrlfrme)
ctrltxt(X).Visible = True
Next
'this is just an example of my textbox control array
For this demonstration, I didn't set the position of the textboxes.
Is there away to use the event on these textboxes?
like ctrltxt(3).text = (val(ctrltxt(1).text) + val(ctrltxt(2).text))
NOTE: I created these textboxes at run time.
I would appreciate any help.
-kol
MSFlexgrid Control Array -keypress Event
I have a MSFlexgrid control array named GridArray(15). I use code to allow the user to enter text to the flexgrid cells.
My problem is when the user selects a cell and enters text it appears not just in the selected flexgrid but in every flexgrid of the array.
This is the code I use;
Private Sub GridArray_KeyPress(Index As Integer, KeyAscii As Integer)
For i = 1 To 15
With GridArray(i)
Select Case KeyAscii
'Usual key capturing code
End Select
End With
Next i
End Sub
I feel I should get rid of the For:Next loop but I have no way of specifing which flexgrid in the array the KeyPress event relates to. I guess I need to pass a value to the 'Index As Integer' argument but dont know how.
Am I right? How can I do this?
Texbox In Control Array Disappears On Its OWN Event
Have any of you experienced an error like so:
VB Code:
Private Sub txtFDetails_Validate(Index As Integer, Cancel As Boolean) Debug.Print txtFDetails(Index).TextEnd Sub
On this event it would cause an error saying that there is no control array element '2'
Obviously there IS, this is its OWN event! and I know for a fact there IS a txtFDetails(2) on the form..
The only pattern I can see when this occurs is that I am passing a reference to this textbox through a few functions and classes, somehow this is messing up VB's own reference list..?
Add Event To Control Array Created At Runtime
Hello everyone,
I've created a form with multiple buttons created at runtime. I cannot seem to attach events to the buttons as they are in a control array. Any ideas?
CODEOption Explicit
Const btnSize = 225
Const spacer = 100
Private Sub btn_Click(Index As Integer)
'only works with button I've created pre runtime
MsgBox (Index)
End Sub
Private Sub cb0_click()
MsgBox ("doesn't work")
End Sub
Private Sub Form_Load()
Dim x As Integer
Dim y As Integer
Dim rowTop As Integer
Dim colLeft As Integer
Dim btnNum As Integer
Dim rowNum As Integer
Dim colNum As Integer
Dim btnTop As Integer
Dim btnLeft As Integer
Dim frameNum As Integer
Dim btn(728) As Control
frameNum = -1
rowTop = 200
colLeft = 50
rowNum = 0
colNum = 0
For y = 0 To 728
If y Mod 81 = 0 Then
frameNum = frameNum + 1
rowNum = 0
colNum = 0
End If
If y Mod 27 = 0 Then
'whole new column
colNum = colNum + 1
rowNum = 1
btnNum = 1
btnTop = rowTop
btnLeft = spacer + (colNum - 1) * ((btnSize * 3) + spacer)
ElseIf y Mod 9 = 0 Then
'new set of numbers
btnNum = 1
rowNum = rowNum + 1
btnTop = btnTop + btnSize + 50
btnLeft = spacer + (colNum - 1) * ((btnSize * 3) + spacer)
ElseIf y Mod 3 = 0 Then
'same numbers down 1 btnSize
btnTop = btnTop + btnSize
btnLeft = spacer + (colNum - 1) * ((btnSize * 3) + spacer)
Else
'just move over 1 btnSize
btnLeft = btnLeft + btnSize
End If
Set btn(y) = Form1.Controls.Add("VB.commandButton", "cb" & y, Frame1(frameNum))
With btn(y)
.Visible = True
.Height = btnSize
.Width = btnSize
.Top = btnTop
.Left = btnLeft
.Caption = btnNum
End With
btnNum = btnNum + 1
Next
End Sub
Unloading Array Controls In Control's Event
Hi,
I'm having this problem with unloading array controls in a control's event (e.g. ComboBox CLICK() event).
Code:
Public Sub Combo1_Click()
Dim i As Integer
For i = Text1.UBOUND To 1 Step -1
Unload obj(i)
Next i
End Sub
It gives error 365 "Unable to unload object within this context". I've checked through and understands that in a few controls events, you can't load or unload controls.
But I need to do it in the control's click event:
My situation is this:
I have a combo box which when the selection changes (CLICK), it will load the controls accordingly. Some selection may load 1 or more TextBox or none.
I can do it under Key_Up() event, but can't do it in Click() event. Well, i can't always just depends on the Key_Up() event. I could create another button to do it but it's inefficient.
I don't understand why does it not allow us to load or unload the controls in those few events... Is there any way to do it? API?
Thanks in advance...
P/S: I've read a post by someone where using timer to do it, I haven't tried it, tough the logic is there, but I still think it's not efficient. Tough, it's one way to do it... currently..
Moving Images From One Control Array To Another By Mouse Click - Resolved
Hi
Wondering if anyone can help?
I have two Control Arrays the first has 50 images in it all with pictures the second has five images in it all without pictures
What I’m trying to do is to move Images from one control array to another by clicking on the mouse button.
I have code set up in the Images DragDrop event allowing me to move the Pictures from the first control array to the second.
I find this to be very time consuming for the user and I think if they also had the option of clicking on the Images in the first Control Array to send the picture to the first available Image in the second Control Array then it would less time consuming for the user.
I can get the picture to move from the first Control Array to the second with the following code
Private Sub ImgDeck_DblClick(Index As Integer)
ImgDeck(Index).Picture = ImgP1Hand(Index).Picture
ImgDeck (Index).Picture = LoadPicture()
ImgDeck (Index).DragIcon = LoadPicture()
End Sub
Which seems ok as far as it goes but it doesn’t take into account whether the Image in the second Control Array all ready has a picture in it and if it does then it simply wipes over it.
What I want to happen is that if ImgHand(0) has a picture in it I want the picture to automatically go to the next image in the Control Array ImgHand(1) etc.. Until all the Images in the second control Array are full the maybe a MsgBox will pop up stating as many cards as possible have been selected.
Does anyone know the code for this?
Any help would be greatly appreciated.
Superfluous Validate Event Call From A Control Button Array
In VB6 (sp6), I have implemented an array of button controls (one for each DateTextBox on a Parent Form), each of which calls a dependent CalendarForm that includes but a single Calendar9 control on it. This form is used to insert its date into the appropriate DateTextBox.
Every executable control on the relevant calling form has its CausesValidation property set to TRUE except for all the control array CalendarForm CallingButtons and the EXIT button.
The problem is this. When a DateTextBox’s associated CallingButton is clicked, the ValidateEvent for the DateTextBox is partially fired even though it should not execute at all. Specifically, the DateTextBox ValidateEvent is executed, but even though the DateTextBox is blank, and therefore lacks a valid date, the ValidateEvent DOES NOT keep the focus on the DateTextBox; it allows the user to proceed with the call to the CalendarForm. When a control array is NOT used for a CalendarForm CallingButton, the code works as expected. That is, the ValidateEvent for the DateTextBox is not fired until a control with a CausesValidation property set to True is pointed to (via, e.g., click or tab). The DateTextBox ValidateEvent also works properly with the control array when I toggle a Breakpoint into the CallingButton array’s ClickEvent.
Does anyone know why the ValidateEvent is executing despite a False CausesValidation property value? I’d prefer a fix for this that retains the control array. Alternatively, is there an obviously superior technique and/or control to use? Thanks for any help.
CODE
{In frm_ppd_data}
Dim ctrlGnrk As Control ' Generic control needed to disable executable controls
Private Enum btnCalendarGrps ' Labels for the button indices
cmdSet_rec_reg_dt = 0
.
.
.
cmdSet_sent_pb_dt = 9
End Enum
Private Sub btnCalendarGrp_Click(Index As Integer)
' For each CalendarCall button, set an object reference to the associated datetextbox
' . . . and provide the title for the CalendarForm identifying the associated date.
NOTE: If I set a breakpoint here, the code runs correctly!?
Set frmCallCalendar = Me ' Identify the form that is calling the CalendarForm
Select Case Index ' Identify the datetextbox that requires a date
Case 0 'cmdSet_rec_reg_dt
Set ctrlDateTextBox = Me.txt_rec_reg_dt
frm_Calendar1.Caption = "Select Date Received by Region Office"
.
.
.
End Select
' Disable all executable controls on the calling form
For Each ctrlGnrk In Me.Controls
If ctrlGnrk.Tag <> "Line" Then
ctrlGnrk.Enabled = False
End If
Next ctrlGnrk
frm_Calendar1.Show ' Get the CalendarForm
End Sub
Private Sub txt_rec_reg_dt_GotFocus()
' Enable the corresponding CalendarForm calling button
btnCalendarGrp(cmdSet_rec_reg_dt).Enabled = True
End Sub
Private Sub txt_rec_reg_dt_Validate(Cancel As Boolean)
' Make sure the text represents a valid date
' Make sure the date makes sense
' Set the boolean switch so that an modified date is Updated to the database
Dim blnCancel As Boolean
Dim strPoorDate As String
blnCancel = False
strPoorDate = "This date cannot be less than 01/01/1980!"
' Call the universal Date Validation subroutine
txtBox_Date_Validation blnKeepFocus:=blnCancel, _
blnTxtDate:=bRec_reg_dt, _
ctrlTxt:=txt_rec_reg_dt, _
strMinDate:="01/01/1980", _
strMsgPoorDate:=strPoorDate
Cancel = blnCancel
End Sub
{In the Mod_call_routine module}
Public Sub txtBox_Date_Validation(ByRef blnKeepFocus As Boolean, _
ByRef blnTxtDate As Boolean, _
ctrlTxt As TextBox, _
strMinDate As String, _
strMsgPoorDate As String)
' Include generic date validation code here.
' Text should compile to a valid date > strMinDate.
' CausesValidation property of all form controls should remain TRUE except "EXIT".
' Hence, if they don't enter a valid date here, they can only EXIT.
Dim strMsgNotDate As String
Dim strMsgTitle As String
strMsgTitle = "INVALID DATE PROBLEM!"
strMsgNotDate = "Please enter a date in this field." & Chr(13) & _
"If you choose not to do so at this time, hit the 'Exit' button."
If Not IsDate(ctrlTxt.Text) Then
blnKeepFocus = True
MsgBox Prompt:=strMsgNotDate, Title:=strMsgTitle
Else
' Attempt to insure an appropriate date.
ctrlTxt.Text = CStr(CDate(ctrlTxt.Text))
If CDate(ctrlTxt.Text) < CDate(strMinDate) Then
blnKeepFocus = True
MsgBox Prompt:=strMsgPoorDate, Title:=strMsgTitle
Else
blnTxtDate = True ' A valid date should be updated into the nm_ppts table.
End If
End If
End Sub
Mouse Up Event Misfired In The Righ Click Event Of The Flexgrid! Help Needed
Hai,
When the user right click the first column of the MSHFlexgrid then a PopUpMenu rises, for that i coded as below. But when the user click the row header which i used to display the Serial No. there also the popupmenu rises. how to avoid this. I am using the below code to identify the First column of the grid and rise the popupmenu.
so i am getting problem. because when the user click a item in the popupmenu then i the next form is show with the value of the MshFlexgrid FirstColumns text..
Private Sub MSHFlexGrid1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton And MSHFlexGrid1.MouseCol = 1 Then
Me.PopupMenu mnuReport
End If
End Sub
How to solve this problm. Kindly suggest your idea.
Thank you very much,
Chock.
itchocks@rediffmail.com
<HTML>
<B><font color="#008000">HAVE A NICE DAY !</font></B>
<HTML>
Click Event On PictureBox Control Does Not Work When AVI Is Opened In PictureBox
Hi,
I want to utilize click event on PictureBox Control. The name of the PictureBox in my code is Display1. The following is the function triggered by Click Event.
Private Sub Display1_Click()
MsgBox "Reached Here"
End Sub
This works fine. But when I open a avi in this PictureBox using mcisendstring, the function is not reached on clicking the PictureBox. What is the reason.
Thanks in advance.
Datagrid Click Event, Dbclick Event.
Hi
I have a datagrid that when I double click on a line it display all the information linked to this line in text box.
I would like to do the same thing with the click event. So when the user click on the grid I call the even dbclick. But the thing is that the click event doesn't seem to have selected the right line yet. Because when I only click it display the information about the old line.
For example I'm on the line1
when I click on the line2 it display me the information of the line1.
Supposed that I still on the the line1
I dbclick on the line2, it display me the information of the line2. (as it supposed to)
I call the same procedure for both click and dbclick event.
Does somebody have any idea how I could solve it?
Thanks in advance
Checking Right Click In Click Event?
Is there any way to detect a right click in a something_click event? I'm trying to do something on both right click and left click for a menu but can't figure it out.
Click Event Executing On More Than Just A Click!
Morning all. On my form today I have a checkbox that can enable or disable a combo box. For this I am using the Click event of the checkbox then an If statement to check its own state and enable/disable the combo. I have a problem however - this check box is also toggled by another event (it's reading data from a recordset) and this also seems to trigger the Click event! I only want the event to trigger if the user actually clicks it with the mouse - I have tried MouseUp and Down... Any ideas?
Lostfocus Event After Click Event
If you use the accelerator for triggering a command button click while focus is on textbox, the command button click goes through first before the text box lostfocus. However if you actually click on the Command button the text box lost focus happens before the command button click which is the right sequence.
How to get the sequence right in the first case?
One way is to do a setfocus in the command button click to itself and issue a DoEvents. But I want to avoid DoEvents since that could lead to triggering of other unexpected events.
Thanks in advance.
|