I have a table that has records with field names as the data that then needs to be matched up with Yes/No fields that uses the same name. So I was planning on looping through the recordset and looping through the tabledef. So in situation below I would loop through the records and where Race_Hold.value = tabledef.field.name set to TRUE/YES. The code I have loops through everything but is not setting the YES/NO field, no errors just isn't doing anything. The debugging shows the RS!fieldname it seems correctly, I don't need brackets as the field names don't have spaces.
Any suggestions would be appreciated (Ms Access 2010)
Thanx
Example: Here we would the looping to update cln_race_white = TRue, cln_race_pacific = true
Client = 100
Race_Hold = cln_race_white
raceAdd_hold = cln_race_pacific
cln_race_black = false
cln_race_white = false
cln_race_pacific = false
Dim db As dao.Database
Dim rs As dao.Recordset
Dim strTemp As String
Dim strTemp2 As String
Dim strTemp3 As String
Dim STRsql As String
Dim strTempALL As String
Dim hyp As Hyperlink
Dim QueryName As String
Dim tdf As dao.TableDef
Dim fld As dao.Field
'Clear Temp Clients
DoCmd.OpenQuery ("qryTemp_exp_Client_Delete")
'Prime Temp Clients
DoCmd.OpenQuery ("qryTEMP_exp_client_append")
Set db = CurrentDb
Set rs = db.OpenRecordset("Temp_exp_client")
Set tdf = db.TableDefs("temp_exp_client")
'Loop through Temp Clients to update races
Do Until rs.EOF
For Each fld In tdf.Fields
strTemp = fld.Name
strTemp2 = "RS!" & strTemp
Debug.Print strTemp2
If rs![race_hold] = strTemp Then
Debug.Print "RH = " & rs![race_hold]
Debug.Print "fldName = " & strTemp
rs.Edit
strTemp2 = YES
'fld.Value = True
rs.Update
Else
End If
If rs![raceAdd_hold] = strTemp Then
rs.Edit
strTemp2 = YES
'fld.Value = True
rs.Update
Else
End If
Next fld
rs.MoveNext
Loop
rs.Close
DoCmd.SetWarnings True
Any suggestions would be appreciated (Ms Access 2010)
Thanx
Example: Here we would the looping to update cln_race_white = TRue, cln_race_pacific = true
Client = 100
Race_Hold = cln_race_white
raceAdd_hold = cln_race_pacific
cln_race_black = false
cln_race_white = false
cln_race_pacific = false
Dim db As dao.Database
Dim rs As dao.Recordset
Dim strTemp As String
Dim strTemp2 As String
Dim strTemp3 As String
Dim STRsql As String
Dim strTempALL As String
Dim hyp As Hyperlink
Dim QueryName As String
Dim tdf As dao.TableDef
Dim fld As dao.Field
'Clear Temp Clients
DoCmd.OpenQuery ("qryTemp_exp_Client_Delete")
'Prime Temp Clients
DoCmd.OpenQuery ("qryTEMP_exp_client_append")
Set db = CurrentDb
Set rs = db.OpenRecordset("Temp_exp_client")
Set tdf = db.TableDefs("temp_exp_client")
'Loop through Temp Clients to update races
Do Until rs.EOF
For Each fld In tdf.Fields
strTemp = fld.Name
strTemp2 = "RS!" & strTemp
Debug.Print strTemp2
If rs![race_hold] = strTemp Then
Debug.Print "RH = " & rs![race_hold]
Debug.Print "fldName = " & strTemp
rs.Edit
strTemp2 = YES
'fld.Value = True
rs.Update
Else
End If
If rs![raceAdd_hold] = strTemp Then
rs.Edit
strTemp2 = YES
'fld.Value = True
rs.Update
Else
End If
Next fld
rs.MoveNext
Loop
rs.Close
DoCmd.SetWarnings True