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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combining Records in A Query

Status
Not open for further replies.

Luggy

MIS
Mar 21, 2000
2
CA
I am trying to combine several duplicate fields into one record. Fields are: VIN(this is the duplicates field), and approximately 30 yes/no fields. I need all the 'yes' fields to over-ride any 'no' fields to combine all the recordsets into one.<br>
<br>
Eg.<br>
<br>
VIN ¦ WC ¦A ¦B ¦C ¦D ¦E ¦F<br>
27715¦ 270 ¦Y ¦n ¦n ¦Y ¦n ¦n<br>
27715¦ 250 ¦n ¦n ¦Y ¦n ¦Y ¦n<br>
27715¦ 240 ¦Y ¦Y ¦n ¦Y ¦n ¦n<br>
<br>
Combined Y Y Y Y Y n<br>
<br>
<br>
I realize i may actually have to write VBA to get this to work properly, because I can't see a way to do it using macros.<br>
<br>
Unfortunately I am just starting to use Access (still in the fetal stage)... lol ... and i know almost no VBA.<br>
<br>
<br>
HELP!<br>
<br>
Luggy<br>
<br>

 
This is a sample that does work<br>
--------------------------------<br>
Public Sub sample(VinNumber)<br>
Dim MyDB As Database, rst As Recordset, SQL As String<br>
Set MyDB = CurrentDb<br>
SQL = &quot;Select * From [Table1] Where [VIN] = '&quot; & VinNumber & &quot;';&quot;<br>
Set rst = MyDB.OpenRecordset(SQL)<br>
rst.MoveLast<br>
rst.MoveFirst<br>
For a = 1 To rst.RecordCount<br>
For b = 2 To 32 'Number of fields starting with the ordinal postion for A<br>
Debug.Print rst.Fields(b).Name<br>
If UCase(rst.Fields(b)) = &quot;N&quot; Then<br>
rst.Edit<br>
rst.Fields(b) = &quot;Y&quot;<br>
rst.Update<br>
End If<br>
Next<br>
rst.MoveNext<br>
Next<br>
rst.Close<br>
MyDB.Close<br>
End Sub<br>
--------------------------------<br>
<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top