473,472 Members | 2,143 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

unable to loop thru records

Using a multi select list box to open several records in a
pre - defined form. Most of the code that follows is taken
from a posting by Alan Browne on his web site. The click
routine is supposed to loop thru all of the reports, or in
this case records, selected in the list box & display them
for previewing or editing. In my situation it only displays 1
record in the form & does not perform the necessary loop.
Have tried futzing with it but getting no where fast.
Hoping someone can direct me to a solution. Below is the onclick() vb code:
Private Sub Command5_Click()
On Error GoTo Err_Handler

Dim varItem As Variant
Dim strWhere As String
Dim strDescrip As String
Dim lngLen As Long
Dim strDelim As String
Dim strDoc As String
strDoc = "EditClipFrm"
With Me.List12
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then

strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","

strDescrip = strDescrip & """" & .Column(1, varItem) & """, "

End If

Next

End With
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[ID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "clipname: " & Left$(strDescrip, lngLen)
End If
End If

DoCmd.OpenForm strDoc, acNormal, WhereCondition:=strWhere

Exit_Handler:
Exit Sub

Err_Handler:
If Err.NUMBER <> 2501 Then
MsgBox "Error " & Err.NUMBER & " - " & Err.Description, , "cmdPreview_Click"
End If
Resume Exit_Handler
End Sub

Thanks as always for any advice on this
dc

May 7 '06 #1
6 1939
doncee <no*****************@charter.net> wrote in
news:Xn*************************@216.196.97.131:
Using a multi select list box to open several records in a
pre - defined form. Most of the code that follows is taken
from a posting by Alan Browne on his web site. The click
routine is supposed to loop thru all of the reports, or in
this case records, selected in the list box & display them
for previewing or editing. In my situation it only displays 1
record in the form & does not perform the necessary loop.
Have tried futzing with it but getting no where fast.
Hoping someone can direct me to a solution. Below is the
onclick() vb code:
This line is wrong: DoCmd.OpenForm strDoc, acNormal, WhereCondition:=strWhere

try,
DoCmd.OpenForm strDoc, acNormal,,strWhere

from the help file:
expression.OpenForm(FormName, View, FilterName, WhereCondition,
DataMode, WindowMode, OpenArgs)
--
Bob Quintal

PA is y I've altered my email address.
May 7 '06 #2
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:
doncee <no*****************@charter.net> wrote in
news:Xn*************************@216.196.97.131:
Using a multi select list box to open several records in a
pre - defined form. Most of the code that follows is taken
from a posting by Alan Browne on his web site. The click
routine is supposed to loop thru all of the reports, or in
this case records, selected in the list box & display them
for previewing or editing. In my situation it only
displays 1 record in the form & does not perform the
necessary loop. Have tried futzing with it but getting no
where fast. Hoping someone can direct me to a solution.
Below is the onclick() vb code:


This line is wrong:
DoCmd.OpenForm strDoc, acNormal,
WhereCondition:=strWhere

try,
DoCmd.OpenForm strDoc, acNormal,,strWhere

from the help file:
expression.OpenForm(FormName, View, FilterName,
WhereCondition, DataMode, WindowMode, OpenArgs)


Thanks for the reply, however I am still getting the same results. The form
opens but only for 1 of the highlited records. I am hoping to open as many
instances of the form as lines I have highlited in the listbox. If I have 4
lines highlited then I would like those 4 records opened in the selected
form. Does this make sense?? Thanks again for your reply.
dc
May 7 '06 #3
doncee <no*****************@charter.net> wrote in
news:Xn*************************@216.196.97.131:
Thanks for the reply, however I am still getting the same results. The
form opens but only for 1 of the highlited records. I am hoping to
open as many instances of the form as lines I have highlited in the
listbox. If I have 4 lines highlited then I would like those 4 records
opened in the selected form. Does this make sense??


The OpenForm code you used will open only one instance of the form with a
recordset of X records, equal to the number of items selected.
If you are sure that the WhereCondition returns more than one record, you
need a way to navigate through the the recordset, either custom controls or
the native navigation buttons.

Richard Bernstein
May 7 '06 #4
doncee <no*****************@charter.net> wrote in
news:Xn*************************@216.196.97.131:
Bob Quintal <rq******@sympatico.ca> wrote in
news:Xn**********************@207.35.177.135:
doncee <no*****************@charter.net> wrote in
news:Xn*************************@216.196.97.131:
Using a multi select list box to open several records in a
pre - defined form. Most of the code that follows is taken
from a posting by Alan Browne on his web site. The click
routine is supposed to loop thru all of the reports, or in
this case records, selected in the list box & display them
for previewing or editing. In my situation it only
displays 1 record in the form & does not perform the
necessary loop. Have tried futzing with it but getting no
where fast. Hoping someone can direct me to a solution.
Below is the onclick() vb code:


This line is wrong:
DoCmd.OpenForm strDoc, acNormal,
WhereCondition:=strWhere

try,
DoCmd.OpenForm strDoc, acNormal,,strWhere

from the help file:
expression.OpenForm(FormName, View, FilterName,
WhereCondition, DataMode, WindowMode, OpenArgs)


Thanks for the reply, however I am still getting the same
results. The form opens but only for 1 of the highlited
records. I am hoping to open as many instances of the form as
lines I have highlited in the listbox. If I have 4 lines
highlited then I would like those 4 records opened in the
selected form. Does this make sense?? Thanks again for your
reply. dc

Your form will open filtered to the records in your list. you
must use the navigation buttons at the bottom of the form to
move between each record, or redesign the form to show multiple
records.

--
Bob Quintal

PA is y I've altered my email address.
May 7 '06 #5
doncee wrote:
Using a multi select list box to open several records in a
pre - defined form. Most of the code that follows is taken
from a posting by Alan Browne on his web site. The click
routine is supposed to loop thru all of the reports, or in
this case records, selected in the list box & display them
for previewing or editing. In my situation it only displays 1
record in the form & does not perform the necessary loop.
Have tried futzing with it but getting no where fast.
Hoping someone can direct me to a solution. Below is the onclick() vb code:
Private Sub Command5_Click()
On Error GoTo Err_Handler

Dim varItem As Variant
Dim strWhere As String
Dim strDescrip As String
Dim lngLen As Long
Dim strDelim As String
Dim strDoc As String
strDoc = "EditClipFrm"
With Me.List12
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then

strWhere = strWhere & strDelim & .ItemData(varItem) & strDelim & ","

strDescrip = strDescrip & """" & .Column(1, varItem) & """, "

End If

Next

End With
lngLen = Len(strWhere) - 1
If lngLen > 0 Then
strWhere = "[ID] IN (" & Left$(strWhere, lngLen) & ")"
lngLen = Len(strDescrip) - 2
If lngLen > 0 Then
strDescrip = "clipname: " & Left$(strDescrip, lngLen)
End If
End If

DoCmd.OpenForm strDoc, acNormal, WhereCondition:=strWhere

Exit_Handler:
Exit Sub

Err_Handler:
If Err.NUMBER <> 2501 Then
MsgBox "Error " & Err.NUMBER & " - " & Err.Description, , "cmdPreview_Click"
End If
Resume Exit_Handler
End Sub

Thanks as always for any advice on this
dc

As Bob said, you might need to set the navigation buttons on. If you
want you could pass an argument to the form if you don't want nav
buttons in certain conditions.
DoCmd.OpenForm strDoc, , , strWhere, , , "Test"

Then in the OnOpen event enter something like
Me.NavigationButtons = (Me.OpenArgs = "Test")
Me.AllowAdditions = Not (Me.OpenArgs = "Test")

If this is not the situation, then add the following code
msgbox strWhere
prior to opening the form. The code you provided us looks OK...not sure
what strDescrip is...but you should be getting a multiple record list.

May 7 '06 #6
salad <oi*@vinegar.com> wrote in
news:kJ***************@newsread2.news.pas.earthlin k.net:

Thanks as always for any advice on this
dc

As Bob said, you might need to set the navigation buttons
on. If you want you could pass an argument to the form if
you don't want nav buttons in certain conditions.
DoCmd.OpenForm strDoc, , , strWhere, , , "Test"

Then in the OnOpen event enter something like
Me.NavigationButtons = (Me.OpenArgs = "Test")
Me.AllowAdditions = Not (Me.OpenArgs = "Test")

If this is not the situation, then add the following code
msgbox strWhere
prior to opening the form. The code you provided us looks
OK...not sure what strDescrip is...but you should be
getting a multiple record list.


Thanks to all who replied. Yes, in fact I do have the filtered
records that I was trying to produce, but I was unknowingly
canceling the form before cycling thru the records. It is clear
now what is happening. Thanks again for all of your help.
dc
May 8 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Charles Alexander | last post by:
Hello I am new to php & MySQL - I am trying to retrieve some records from a MySQL table and redisplay them. The data in list form looks like this: Sample_ID Marker_ID Variation ...
2
by: Les Juby | last post by:
I have an application which loops through several thousand subscriber records, compares each subscriber's requirements to a database of businesses for sale, and then prepares and mails off an email...
1
by: Eric Martin | last post by:
Hello, Does anyone know of a way to loop thru a SQL table using code in a stored procedure? I need to go thru each record in a small table and build a string using values from the fields...
1
by: Jeremy Langworthy | last post by:
Hi I have a dynamicly generated form (well the elements are at least) that looks something like this: while( not end of returned records): <input name="plan_id" type="checkbox" id=""...
4
by: Radu | last post by:
Hi. It seems to be very simple, actually, but I don't know if it is feasible in TSQL. I have a sproc which gathers in one place many calls to different other sprocs, all of them taking a...
16
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataAdapter. For every record in tblA where colB = 'abc', I want to update the value in colA. In VB6, using ADO I can loop thru the recordset,set the...
3
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Here is my loop and it runs fine: ---------------------------------------------------- sSQL = "SELECT * FROM STORE_ITEMS" Set DataRec = DB.execute(sSQL) if not DataRec.EOF then do while not...
8
by: SaltyBoat | last post by:
Needing to import and parse data from a large PDF file into an Access 2002 table: I start by converted the PDF file to a html file. Then I read this html text file, line by line, into a table...
1
by: sausthav | last post by:
Hi All, I am unable to get the excel open when user select two dates from my code. Previously i was successfully extracting values by selecting year and month values from the webpage. Could you help...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.