Problem witrh list box & forms code

D

David McKnight

I have a forms code that I want to use a value in a list box but it doesn't
seem to refresh when I run the code.

List box [ListLoops] use row source from a table [Loops] bound to second
column. Values are 1, 2, 4, 8, 16..etc

Default value is set at 2048 and this is the only when the code uses, unless
a change the default value exit and save form and restart then it only uses
the new default value no matter what I change it to in the drop down list box.
 
J

Jeanette Cunningham

Hi David,
how are you getting the value from the listbox?
Are you using some code a bit like this code below:

If Len(Me.ListLoops & vbNullString) >0 Then
Me.TheTextBox = Me.ListLoops
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

David McKnight

Yes,

I'm using it as input to determine number of times a loop query will loop.

I've tried several ways, ie"

Loops= me.ListLoops.Value
Loop Until myNum = Loops

Or
Loop Until myNum = me.ListLoops.Value

But all it uses is the default value. I use a textbox on the same form to
get values for other parts of code and that works fine - it's just the
listbox(es) values that don't seem to update.

--
David McKnight


Jeanette Cunningham said:
Hi David,
how are you getting the value from the listbox?
Are you using some code a bit like this code below:

If Len(Me.ListLoops & vbNullString) >0 Then
Me.TheTextBox = Me.ListLoops
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



David McKnight said:
I have a forms code that I want to use a value in a list box but it doesn't
seem to refresh when I run the code.

List box [ListLoops] use row source from a table [Loops] bound to second
column. Values are 1, 2, 4, 8, 16..etc

Default value is set at 2048 and this is the only when the code uses,
unless
a change the default value exit and save form and restart then it only
uses
the new default value no matter what I change it to in the drop down list
box.
 
J

Jeanette Cunningham

Sorry David, I'm not quite understanding what you are trying to do.
If you use Me.ListLoops.Value - you get the value for the currently
selected item of the listbox. Is this what you want? If no item is selected
by the user, you will most likely get the value corresponding to the first
item on the list.

Find the value for loops like this-->
Loops = Me.ListLoops
Debug.Print Loops


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


David McKnight said:
Yes,

I'm using it as input to determine number of times a loop query will loop.

I've tried several ways, ie"

Loops= me.ListLoops.Value
Loop Until myNum = Loops

Or
Loop Until myNum = me.ListLoops.Value

But all it uses is the default value. I use a textbox on the same form to
get values for other parts of code and that works fine - it's just the
listbox(es) values that don't seem to update.

--
David McKnight


Jeanette Cunningham said:
Hi David,
how are you getting the value from the listbox?
Are you using some code a bit like this code below:

If Len(Me.ListLoops & vbNullString) >0 Then
Me.TheTextBox = Me.ListLoops
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



message
I have a forms code that I want to use a value in a list box but it
doesn't
seem to refresh when I run the code.

List box [ListLoops] use row source from a table [Loops] bound to
second
column. Values are 1, 2, 4, 8, 16..etc

Default value is set at 2048 and this is the only when the code uses,
unless
a change the default value exit and save form and restart then it only
uses
the new default value no matter what I change it to in the drop down
list
box.
 
D

David McKnight

Right. But problem is that I DO select and different value than the default
value, but the code still uses the default value as if the selection is not
being refreshed.
--
David McKnight


Jeanette Cunningham said:
Sorry David, I'm not quite understanding what you are trying to do.
If you use Me.ListLoops.Value - you get the value for the currently
selected item of the listbox. Is this what you want? If no item is selected
by the user, you will most likely get the value corresponding to the first
item on the list.

Find the value for loops like this-->
Loops = Me.ListLoops
Debug.Print Loops


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


David McKnight said:
Yes,

I'm using it as input to determine number of times a loop query will loop.

I've tried several ways, ie"

Loops= me.ListLoops.Value
Loop Until myNum = Loops

Or
Loop Until myNum = me.ListLoops.Value

But all it uses is the default value. I use a textbox on the same form to
get values for other parts of code and that works fine - it's just the
listbox(es) values that don't seem to update.

--
David McKnight


Jeanette Cunningham said:
Hi David,
how are you getting the value from the listbox?
Are you using some code a bit like this code below:

If Len(Me.ListLoops & vbNullString) >0 Then
Me.TheTextBox = Me.ListLoops
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



message
I have a forms code that I want to use a value in a list box but it
doesn't
seem to refresh when I run the code.

List box [ListLoops] use row source from a table [Loops] bound to
second
column. Values are 1, 2, 4, 8, 16..etc

Default value is set at 2048 and this is the only when the code uses,
unless
a change the default value exit and save form and restart then it only
uses
the new default value no matter what I change it to in the drop down
list
box.
 
J

Jeanette Cunningham

It sounds like the selected value is not being passed to the loops code.
If you post all the relevant parts of the code, we can help further.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



David McKnight said:
Right. But problem is that I DO select and different value than the
default
value, but the code still uses the default value as if the selection is
not
being refreshed.
--
David McKnight


Jeanette Cunningham said:
Sorry David, I'm not quite understanding what you are trying to do.
If you use Me.ListLoops.Value - you get the value for the currently
selected item of the listbox. Is this what you want? If no item is
selected
by the user, you will most likely get the value corresponding to the
first
item on the list.

Find the value for loops like this-->
Loops = Me.ListLoops
Debug.Print Loops


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


message
Yes,

I'm using it as input to determine number of times a loop query will
loop.

I've tried several ways, ie"

Loops= me.ListLoops.Value
Loop Until myNum = Loops

Or
Loop Until myNum = me.ListLoops.Value

But all it uses is the default value. I use a textbox on the same form
to
get values for other parts of code and that works fine - it's just the
listbox(es) values that don't seem to update.

--
David McKnight


:

Hi David,
how are you getting the value from the listbox?
Are you using some code a bit like this code below:

If Len(Me.ListLoops & vbNullString) >0 Then
Me.TheTextBox = Me.ListLoops
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



message
I have a forms code that I want to use a value in a list box but it
doesn't
seem to refresh when I run the code.

List box [ListLoops] use row source from a table [Loops] bound to
second
column. Values are 1, 2, 4, 8, 16..etc

Default value is set at 2048 and this is the only when the code
uses,
unless
a change the default value exit and save form and restart then it
only
uses
the new default value no matter what I change it to in the drop down
list
box.
 
D

David McKnight

Hard to say what is relevent but I think this the section of code that list
box is used I'll post it:

Private Sub cmdDiv1ARanking_Click()
Me.Repaint

' Loop Seasons

SeasonCounter = 0
mySeasonNum = Me.txtSeason.Value - 1
Do
mySeasonNum = mySeasonNum + 1
txtSeason.Value = mySeasonNum
lblYear.Caption = mySeasonNum

txtEstCompletion.Visible = True

Me.Repaint
DoEvents

'Start timer

txtTimeStart.Value = Now
Loops = txtLoops.Value
EndSeason = txtEndSeason.Value
BeginSeason = txtSeason.Value
Week = ListWeek.Value


txtTimeFinished.Value = Now
txtTotalTime.Value = txtTimeFinished.Value - txtTimeStart.Value
Text_LoopNo.Value = "Starting"
Me.Repaint
DoEvents

counter = 0

' strSql = "DELETE * FROM [Filter Parameters]"
'CurrentDb.Execute strSql, dbFailOnError


'BEGIN MAKE QUERY "Scores-Win Loss"

Dim db As DAO.Database
Dim qdf As DAO.QueryDef

Set db = CurrentDb()

' Load querydef if it exists; create it if it doesn't.
'On Error Resume Next ' disable error-handling
Set qdf = db.QueryDefs("Scores-Win Loss")
'On Error GoTo Err_Handler ' establish error-handling
If qdf Is Nothing Then
Set qdf = db.CreateQueryDef("Scores-Win Loss")
End If





' Set the query's SQL

qdf.SQL = "SELECT Scores.ID, Scores.Date, Scores.Season, [Scores].[Season]+1
AS [Season-1], Scores.Visitor, Scores.[Visitor Score], Scores.Home,
Scores.[Home Score], " & _
"Scores.Margin, Scores.Nuetral, Scores.Location, Scores.Location2,
Scores.Line, IIf(Scores!Margin=0,0,((Scores!Margin)/(Abs(Scores!Margin)))) AS
[Win-Loss], " & _
"1+(([Home Score]+10)/([Home Score]+[Visitor Score]+20)) AS [Percent
Margin],
IIf(Abs([Margin])=0,0,(Log(Abs([Margin])))*([Margin]/(Abs([Margin])))) AS
[Adj Log Margin], " & _
"IIf(Scores!Nuetral=0,Scores!Margin-Coefficients![Home Field Adv
Margin],Scores!Margin) AS [Adjusted Margin], IIf(Scores!Nuetral=0, " & _
"[Win-Loss]-Coefficients![Home Field AdvWin-Loss],[Win-Loss]) AS [Adjusted
Margin Win-Loss], [Scores]![Date] &
IIf(RTrim([Scores]![Home])<RTrim([Scores]![Visitor])," & _
"RTrim([Scores]![Home]) &
RTrim([Scores]![Visitor]),RTrim([Scores]![Visitor]) & RTrim([Scores]![Home]))
AS Game, " & _
"IIf(RTrim([Scores]![Home])<RTrim([Scores]![Visitor]),RTrim([Scores]![Home])
& RTrim([Scores]![Visitor]),RTrim([Scores]![Visitor]) &
RTrim([Scores]![Home])) AS Series, " & _
"Format([Scores].[Date],'ww') AS Week, +[Season] & [Home] AS SeasonHome,
+[Season] & [Visitor] AS SeasonVisitor " & _
"FROM Coefficients, Scores " & _
"WHERE (((Scores.Season)= " & Me.txtSeason.Value & "))AND
(((Format([Scores].[Date],'ww'))<= " & Me.ListWeek.Value & "));"




--
David McKnight


Jeanette Cunningham said:
It sounds like the selected value is not being passed to the loops code.
If you post all the relevant parts of the code, we can help further.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



David McKnight said:
Right. But problem is that I DO select and different value than the
default
value, but the code still uses the default value as if the selection is
not
being refreshed.
--
David McKnight


Jeanette Cunningham said:
Sorry David, I'm not quite understanding what you are trying to do.
If you use Me.ListLoops.Value - you get the value for the currently
selected item of the listbox. Is this what you want? If no item is
selected
by the user, you will most likely get the value corresponding to the
first
item on the list.

Find the value for loops like this-->
Loops = Me.ListLoops
Debug.Print Loops


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


message
Yes,

I'm using it as input to determine number of times a loop query will
loop.

I've tried several ways, ie"

Loops= me.ListLoops.Value
Loop Until myNum = Loops

Or
Loop Until myNum = me.ListLoops.Value

But all it uses is the default value. I use a textbox on the same form
to
get values for other parts of code and that works fine - it's just the
listbox(es) values that don't seem to update.

--
David McKnight


:

Hi David,
how are you getting the value from the listbox?
Are you using some code a bit like this code below:

If Len(Me.ListLoops & vbNullString) >0 Then
Me.TheTextBox = Me.ListLoops
End If


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



message
I have a forms code that I want to use a value in a list box but it
doesn't
seem to refresh when I run the code.

List box [ListLoops] use row source from a table [Loops] bound to
second
column. Values are 1, 2, 4, 8, 16..etc

Default value is set at 2048 and this is the only when the code
uses,
unless
a change the default value exit and save form and restart then it
only
uses
the new default value no matter what I change it to in the drop down
list
box.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top