I am trying to copy some data from one table to another, but not in a simple way. I need to look up an index number, then using that record, cycle through all the fields past field 11, and for every non-null entry, copy both the entry as well as the name of the field in to my new table.
Here's my code:
I have no idea if it works, as it throws an error at me for this:
Set FieldName = fld.Name
I have no idea why.
Any and all help, as always, is greatly appreciated!
Here's my code:
Code:
Dim dbsNecropsy As DAO.Database
Dim rstGenotypes As DAO.Recordset
Dim fld As DAO.Field
Dim FieldName As String
Dim Blah As Integer
Set dbsNecropsy = CurrentDb
Set rstGenotypes = dbsNecropsy.OpenRecordset("FacilityTyping", dbOpenTable)
rstGenotypes.Index = "Animal UID"
rstGenotypes.Seek "=", [Mouse UID]
If rstGenotypes.NoMatch Then
MsgBox "Genotypes for UID could not be found."
Else
[Gender] = rstGenotypes!Sex
For Blah = 11 To rstGenotypes.Fields.Count - 1
Set fld = rstGenotypes(Blah)
Set FieldName = fld.Name
If IsNull(rstGenotypes!FieldName) Then
Next
Else
["Gene" & Blah] = rstGenotypes!FieldName
["Allele" & Blah] = FieldName
End If
Next
End If
Set FieldName = fld.Name
I have no idea why.
Any and all help, as always, is greatly appreciated!