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!

Listbox on click - Is this an Access 200 bug?

Status
Not open for further replies.

SonicBoomBand

Technical User
Jun 4, 2004
42
0
0
GB
I have a form and on the form I have a list box which onclick will populate text boxes with the data held in the list box enabling a user to change and save the data.

However, for some very annoying reason, whatever I click on in the form (i.e. command buttons) the list box onclick code runs first and doesn't run the command button code.

I have tried recreating the form, this does not help.

Is this a known bug? Is there somebody out there that has come across this before and worked out a fix?

Any help would be gratefully received as my laptop has nearly gone out the window several times.

Thank you

Andrew Chamberlain
National Grid
 
Can you post the code for the listbox, including the declaration portion (Private Sub Listbox1_OnClick(...) Handles etc). It sounds like you have more than one handles listed. You may also try to set a breakpoint in the code somewhere, probably on one of the other buttons, to see if they are not calling/referencing the code for the listbox in any way.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB/Access Programmer
 
It's pretty straight forward stuff. There is definately no code calling this onclick event.

Bit of extra info on the whats happening in the code. It's pulling it's data from a sql server table. txtDate, txtEffFrom and txtEffTo are activeX date controls, txtEnteredBy and txtEnteredOn are normal text boxes.

------------------------------------------
Private Sub lstLimits_Click()

Dim qd As QueryDef
Dim rs As Recordset
Dim sql As String

On Error GoTo error_trap

Set qd = CurrentDb.CreateQueryDef("")

With qd
.Connect = Constr
.sql = "SELECT HorizonLimit, EffectiveFrom, EffectiveTo, EnteredBy, EnteredOn " & _
"FROM TradeHorizonLimit " & _
"WHERE HorizonLimit = '" & Format(Me.lstLimits, "dd-mmm-yyyy") & "'"
.ReturnsRecords = True
Set rs = qd.OpenRecordset(dbOpenSnapshot)
.Close
End With

Me.txtDate.Enabled = True
Me.txtEffFrom.Enabled = True
Me.txtEffTo.Enabled = True

Me.txtDate.Value = rs("HorizonLimit")
Me.txtEffFrom.Value = rs("EffectiveFrom")
Me.txtEffTo.Value = IIf(IsNull(rs("effectiveto")), Null, rs("effectiveto"))
Me.txtEnteredBy = rs("EnteredBy")
Me.txtEnteredOn = rs("EnteredOn")

Me.txtDate.Enabled = False
Me.txtEffFrom.Enabled = False
Me.txtEffTo.Enabled = False

If Me.txtReadOnlyUser = False Then
Me.cmdEdit.Enabled = True
End If

rs.Close

Exit Sub

error_trap:
error_trap Err, Error$, "lstLimits_Click()", Me.Name

End Sub
------------------------------------------

Regards

Andrew Chamberlain
National Grid
 
how are ya SonicBoomBand . . .

You should be running your listbox code in the listbox AfterUpdate event. This is the perferred event.

Move your listbox code there and try again . . .

Calvin.gif
See Ya! . . . . . .
 
Cheers for your comments.

I can't move the code to AfterUpdate, because by clicking on the list box, I'm not updating, so doesn't run the code.

Good news though, I've found the problem.

If you turn the tab stop option off for the list box, the issue is resolved.

Andrew Chamberlain
National Grid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top