Referencing a Filed name in VB Code

  • Thread starter Thread starter Graham M Haines
  • Start date Start date
G

Graham M Haines

I want to check if 16 fields in a recordset are null or not. The Filed
names are Module01, Module02, Module02 etc

I am assigning the name of the field to a variable and then checking if
filed value is null or not. I am having problems referencing the fields
name

For intmodfieldcnt = 1 To 16 '
If intmodfieldcnt < 10 Then
strfldname = "Module" & "0" & intmodfieldcnt
Else
strfldname = "Module" & intmodfieldcnt
End If

with rst
If Not IsNull(rst.Field(strfldname) Then ' This is the problem line
Do subroutine
Else
Skip
End if
End With

--
Regards

Graham

Graham Haines
 
Graham said:
I want to check if 16 fields in a recordset are null or not. The
Filed names are Module01, Module02, Module02 etc

I am assigning the name of the field to a variable and then checking
if filed value is null or not. I am having problems referencing the
fields name

For intmodfieldcnt = 1 To 16 '
If intmodfieldcnt < 10 Then
strfldname = "Module" & "0" & intmodfieldcnt
Else
strfldname = "Module" & intmodfieldcnt
End If

with rst
If Not IsNull(rst.Field(strfldname) Then ' This is the problem line
Do subroutine
Else
Skip
End if
End With

I believe you are missing an "s".

rst.Fields(strfldname)
^
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top