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

OnClick event firing twice

Status
Not open for further replies.

sarahnice

Technical User
Nov 18, 2002
101
0
0
IE
Hi,

I have a number of Labels on a form, each one having an onclick event associated with them. The onclick event opens a different form in design view, deletes the elements, adds some new elements to it, saves the form and then opens the form in normal view to display to the user.

When i click on one of these labels, the second form is opened in design view. I can see the elements being deleted, then added and then the form closes. Next the form is opened in design view again and i can see the elements being deleted, added and then the form is closed. It is at this point that the form opens in normal view to display to the user.

Can anyone help. It seems that the onClick event is being fired twice. The form is definitely being opened twice because when i add a msgbox command to the onLoad event of the form being opened, it pops up twice.

There is nothing in the onLoad event of the second form that would cause this.

Any help would be greatly appreciated.

Thanks :)
 
Sara,
It would be helpful to see your code for this question.
 
This is the code to create the label on the form. I use an onMouseUp event but it has the same effect as the onClick event (event firing twice).

The below code is within a for loop with some other stuff which has no effect on the label creation.

With CreateControl("ManageTimeline", acLabel, acDetail, "", "", ((elementWidth * j) + leftPos), elementTop - 250, elementWidth, elementHeight)
.name = "txtGroupHeader" & j
.ForeColor = RGB(255, 255, 255)
.FontName = "tahoma"
.FontSize = 7
.TextAlign = 2
.Visible = True
.BackStyle = 1
.BackColor = RGB(128, 128, 192)
.BorderStyle = 1
.Caption = "Label" & j
.OnMouseUp = "=viewBooking(" & j & ")"
End With

The viewBooking sub simply opens a form in design view, adds some elements to it, saves it and then open it in normal view.

DoCmd.openForm "CreateTask"

I hope you can help me cause it's driving me mad.

Thanks
 
Sarah,
I apologize for not getting back to you. I am kind of new in this exchange and just learned of "MyThreads". I had gotton busy and lost track.
I hope you found a solution to your problem. From the code you provided, my first suspicion is the index j in upper loop. This index may be causing the unwanted double cycle.
Jeff
 
Just a thought. If you are working with labels to create bars as in a bar chart to show progress, or you are using a form for another reason but need labels appearing depending on certain conditions - then consider creating a form in Design View using a Control Array(s). After you have all the labels in the control arry set up, then change their Visible property to No. During User run-time, your code could respond to any conditions by turning the Visible property to Yes.

Jeff Logan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top