Re: Output data from multiple records in a table
- From: John Nurick <j.mapSoN.nurick@xxxxxxxxxxxxxx>
- Date: Thu, 07 Jul 2005 21:55:32 +0100
Hi Dave,
I think you're making more of a meal of this than strictly necessary.
Something like this air code will get you a recordset containing the
records you want and then stuff the contents of the fields into a
string. it works regardless of the number of records found
I'm assuming the primary key field is called RecName and that it's
displayed on the form in a textbox called txtRecName:
Dim rsR As DAO.Recordset
Dim strSQL As String
Dim j As Long
Dim strStuff As String
strSQL = "SELECT * FROM OtherTable " _
& " IN 'C:\Folder\Folder\OtherDB.mdb' WHERE RecName='" _
& Me.txtRecName.Value & "';"
Set rsR = CurrentDB.OpenRecordset(strSQL)
Do While Not rsR.EOF
With rsR
For j = 0 to .Fields.Count - 1
strStuff = Nz(.Fields(j).Value, "") & vbCrLf
Next
.MoveNext
End With
Loop
rsR.Close
Having got all the data into a string you can do what you want with it,
such as display it in a textbox on your form. (For most purposes, it
seems to me, it would be more useful just to open another form with the
data you've found.)
On Wed, 6 Jul 2005 23:56:02 -0700, "Dave"
<Dave@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>I have an application which displays data from a table on a form. I have
>written code such that when you double click on a field on the form, it opens
>another database, finds the record whose name matches the data in the field
>(name being the PrimaryKey in the second table), then dumps the contents of
>the other record into wordpad for display on the screen. (The code uses
>MyTable.seek to match the unique record and then the TableDefs property to
>get the data from all fields for that record). So far, so good...
>
>What I need to do now is to be able to click on another field, find the
>matching record in another remote table and do the same thing for a table
>which contains duplicates, i.e., I want to dump the contents of all matching
>records into Wordpad. (There are two indexes on the second table, one on name
>and another one which is indexed on name and another field)
>
>Can anyone see what I'm trying to do and help please ? Do I need to use an
>SQL query ? If so, I'm struggling to get the syntax right
>
>any help much appreciated
>Dave
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
.
- Follow-Ups:
- References:
- Output data from multiple records in a table
- From: Dave
- Output data from multiple records in a table
- Prev by Date: Re: Field change color when a date is about to be due or is past d
- Next by Date: RE: Want to get table record count
- Previous by thread: Output data from multiple records in a table
- Next by thread: Re: Output data from multiple records in a table
- Index(es):
Relevant Pages
|