URGENT,need help with listbox

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

HI!!

I would like to know if I can send the results presently
stored in one of my recordSets to a ListBox.

Here's my code:
number = Text1.Value

Set qd = db.QueryDefs![replaceWojoForOrderNumberInMedical]
qd.Parameters![Prnbr] = number

Set rs = qd.OpenRecordset()

' here I've put my 'qd' in a recordSet to check
RecordCount.

cpt = rs.RecordCount
If cpt = 0 Then
MsgBox "No data was found for this number: " & number
& ",try again!"
Text1.Value = Null
Text1.SetFocus
Else
lrep.RowSource = rs 'list box
end if

'lrep' being my listbox. CAN it be done.Perhaps you see
another way of doing things.PLEASE HELP!!

thanx in advance
PAtrick
 
Assuming that you don't have a huge list, you can concatenate the list of
field values into a List and use that as the row source:

Replace
lrep.RowSource = rs 'list box

with this code snippet (assumes that the first field in the recordset is the
one to show in the list box):
Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value ^ ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList
 
Thanx Ken!!!
I will give this a try.
-----Original Message-----
Assuming that you don't have a huge list, you can concatenate the list of
field values into a List and use that as the row source:

Replace
lrep.RowSource = rs 'list box

with this code snippet (assumes that the first field in the recordset is the
one to show in the list box):
Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value ^ ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList


--
Ken Snell
<MS ACCESS MVP>

HI!!

I would like to know if I can send the results presently
stored in one of my recordSets to a ListBox.

Here's my code:
number = Text1.Value

Set qd = db.QueryDefs! [replaceWojoForOrderNumberInMedical]
qd.Parameters![Prnbr] = number

Set rs = qd.OpenRecordset()

' here I've put my 'qd' in a recordSet to check
RecordCount.

cpt = rs.RecordCount
If cpt = 0 Then
MsgBox "No data was found for this number: " & number
& ",try again!"
Text1.Value = Null
Text1.SetFocus
Else
lrep.RowSource = rs 'list box
end if

'lrep' being my listbox. CAN it be done.Perhaps you see
another way of doing things.PLEASE HELP!!

thanx in advance
PAtrick


.
 
Noted a typo in the code snippet. Here is corrected version:

Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value & ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList

--
Ken Snell
<MS ACCESS MVP>
Patrick said:
Thanx Ken!!!
I will give this a try.
-----Original Message-----
Assuming that you don't have a huge list, you can concatenate the list of
field values into a List and use that as the row source:

Replace
lrep.RowSource = rs 'list box

with this code snippet (assumes that the first field in the recordset is the
one to show in the list box):
Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value ^ ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList


--
Ken Snell
<MS ACCESS MVP>

HI!!

I would like to know if I can send the results presently
stored in one of my recordSets to a ListBox.

Here's my code:
number = Text1.Value

Set qd = db.QueryDefs! [replaceWojoForOrderNumberInMedical]
qd.Parameters![Prnbr] = number

Set rs = qd.OpenRecordset()

' here I've put my 'qd' in a recordSet to check
RecordCount.

cpt = rs.RecordCount
If cpt = 0 Then
MsgBox "No data was found for this number: " & number
& ",try again!"
Text1.Value = Null
Text1.SetFocus
Else
lrep.RowSource = rs 'list box
end if

'lrep' being my listbox. CAN it be done.Perhaps you see
another way of doing things.PLEASE HELP!!

thanx in advance
PAtrick


.
 
No problemo, I notice-it when pasting in VBA. so I
corrected-it and the code works great, thanks again!
-----Original Message-----
Noted a typo in the code snippet. Here is corrected version:

Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value & ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList

--
Ken Snell
<MS ACCESS MVP>
Thanx Ken!!!
I will give this a try.
-----Original Message-----
Assuming that you don't have a huge list, you can concatenate the list of
field values into a List and use that as the row source:

Replace
lrep.RowSource = rs 'list box

with this code snippet (assumes that the first field in the recordset is the
one to show in the list box):
Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value ^ ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList


--
Ken Snell
<MS ACCESS MVP>

"Patrick" <[email protected]> wrote
in
message
HI!!

I would like to know if I can send the results presently
stored in one of my recordSets to a ListBox.

Here's my code:
number = Text1.Value

Set qd = db.QueryDefs! [replaceWojoForOrderNumberInMedical]
qd.Parameters![Prnbr] = number

Set rs = qd.OpenRecordset()

' here I've put my 'qd' in a recordSet to check
RecordCount.

cpt = rs.RecordCount
If cpt = 0 Then
MsgBox "No data was found for this number: " & number
& ",try again!"
Text1.Value = Null
Text1.SetFocus
Else
lrep.RowSource = rs 'list box
end if

'lrep' being my listbox. CAN it be done.Perhaps you see
another way of doing things.PLEASE HELP!!

thanx in advance
PAtrick


.


.
 
You're welcome.

Patrick said:
No problemo, I notice-it when pasting in VBA. so I
corrected-it and the code works great, thanks again!
-----Original Message-----
Noted a typo in the code snippet. Here is corrected version:

Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value & ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList

--
Ken Snell
<MS ACCESS MVP>
Thanx Ken!!!
I will give this a try.

-----Original Message-----
Assuming that you don't have a huge list, you can
concatenate the list of
field values into a List and use that as the row source:

Replace
lrep.RowSource = rs 'list box

with this code snippet (assumes that the first field in
the recordset is the
one to show in the list box):
Dim strList As String
strList = ""
rs.MoveFirst
Do While rs.EOF = False
strList = strList & rs.Fields(0).Value ^ ";"
rs.MoveNext
Loop
strList = Left(strList, Len(strList) - 1)
lrep.RowSource = strList


--
Ken Snell
<MS ACCESS MVP>

message
HI!!

I would like to know if I can send the results presently
stored in one of my recordSets to a ListBox.

Here's my code:
number = Text1.Value

Set qd = db.QueryDefs!
[replaceWojoForOrderNumberInMedical]
qd.Parameters![Prnbr] = number

Set rs = qd.OpenRecordset()

' here I've put my 'qd' in a recordSet to check
RecordCount.

cpt = rs.RecordCount
If cpt = 0 Then
MsgBox "No data was found for this number: " &
number
& ",try again!"
Text1.Value = Null
Text1.SetFocus
Else
lrep.RowSource = rs 'list box
end if

'lrep' being my listbox. CAN it be done.Perhaps you see
another way of doing things.PLEASE HELP!!

thanx in advance
PAtrick


.


.
 
Back
Top