And the answer to that is? It matters.Is that Yes text or is it a Y/N field - aka Boolean, True/False, -1/0 ??
Do you need to know what record contains the value or not?Regardless, how much help is it to know that there is a yes in a field when you don't know which of the 7,000 records it is in?
Is that Yes text or is it a Y/N field - aka Boolean, True/False, -1/0 ??And the answer to that is? It matters.
Do you need to know what record contains the value or not?
If so, how is the record identified - perhaps the first field is the unique record ID?
Name of Field_0 | Name of Field_1 | Name of Field_2 | Name of Field_3 | Name of Field_4 | Name of Field_5 | Name of Field_6 |
Record_ID_1 | Yes | xxx | Yes | xxx | xxx | xxx |
Record_ID_47 | xxx | xxx | xxx | xxx | Yes | xxx |
Record_ID_98 | Yes | xxx | Yes | xxx | xxx | Yes |
Record_ID_451 | xxx | xxx | xxx | Yes | xxx | xxx |
Record_ID_770 | Yes | xxx | xxx | xxx | xxx | xxx |
Record_ID_771 | Yes | xxx | xxx | xxx | xxx | xxx |
Record_ID_1000 | Yes | xxx | xxx | xxx | xxx | xxx |
Record_ID_1600 | Yes | xxx | xxx | xxx | xxx | xxx |
Record_ID_4000 | Yes | xxx | xxx | xxx | xxx | xxx |
Record_ID_1395 | xxx | xxx | Yes | XX | XX | XX |
Record_ID_1396 | xxx | xxx | Yes | XX | XX | XX |
Field_Name | Unique Key |
Name of Field_1 | Record_ID_1 |
Record_ID_770 | |
Record_ID_771 | |
Record_ID_1000 | |
Record_ID_1600 | |
Record_ID_4000 | |
Name of Field_4 | Record_ID_1600 |
Name of Field_3 | Record_ID_1393 |
Record_ID_1394 | |
Record_ID_1395 | |
Record_ID_1396 | |
Name of Field_4 | Record_ID_451 |
Name of Field_5 | Record_ID_47 |
Name of Field_6 | Record_ID_98 |
I think you misunderstood that because you said no then showed which record has the yes value in it (e.g. Record_ID_1)Do you need to know what record contains the value or not?
-No, it is dynamic records
Function dhen21dx()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim i As Integer
Dim sql As String
On Error GoTo errHandler
Set db = CurrentDb
Set rs = db.OpenRecordset("tblYesValues", dbOpenSnapshot)
rs.MoveFirst
If Not (rs.BOF And rs.EOF) Then
db.Execute "DELETE * FROM tblYes", dbFailOnError
Do Until rs.EOF
For i = 1 To rs.Fields.Count - 1
If rs.Fields(i) = "Yes" Then
sql = "INSERT INTO tblYes (RecID, FieldName) VALUES (" & rs.Fields(0) & ",'" & rs.Fields(i).Name & "')"
db.Execute sql, dbFailOnError
End If
Next i
rs.MoveNext
Loop
End If
exitHere:
On Error Resume Next
rs.Close
Set rs = Nothing
Set db = Nothing
Exit Function
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
Resume exitHere
End Function
YesID | RecID | FieldName |
---|---|---|
9 | 1 | field1 |
10 | 1 | field3 |
11 | 2 | field2 |
12 | 2 | field4 |
13 | 3 | field3 |
14 | 3 | field4 |
15 | 3 | field5 |
Hi Micron,Here's what my small sample results in when code is run
tblYes
YesID > perhaps useful, perhaps not. I would advise to have it.
YesID RecID FieldName 9 1field1 10 1field3 11 2field2 12 2field4 13 3field3 14 3field4 15 3field5
RecID > the autonumber (unique id from the Yes records.
FieldName > the field name containing Yes in that record ID