go through numbered records

  • Thread starter Thread starter Katrina
  • Start date Start date
K

Katrina

I have fields named [P/N01], [P/N02].... to [P/N30]

What I would like to do it have access determine which
field is the first empty field and put some info into it.
I thought that a for loop would work well, so below is the
code I have so far, however it's not quite working. Any
suggestions?

countnum = 1
For countnum = 1 To 30
fldname = Format$(countnum, """P/N""00")
fllname = "[Forms]![0 P/N Summary]!" &
Format$(countnum, """P/N""00")
If fllname = Null Then
fllname = Format$(countnum, """test""00")
countnum = 31
Else
countnum = countnum + 1
End If
Next countnum
 
Katrina,
If fllname = Null Then 'You can't compare to Null this way, the result will
always be false.
if isnull(fllname) then ' Correct way.

Alex.

Katrina said:
I have fields named [P/N01], [P/N02].... to [P/N30]

What I would like to do it have access determine which
field is the first empty field and put some info into it.
I thought that a for loop would work well, so below is the
code I have so far, however it's not quite working. Any
suggestions?

countnum = 1
For countnum = 1 To 30
fldname = Format$(countnum, """P/N""00")
fllname = "[Forms]![0 P/N Summary]!" &
Format$(countnum, """P/N""00")
If fllname = Null Then
fllname = Format$(countnum, """test""00")
countnum = 31
Else
countnum = countnum + 1
End If
Next countnum
 
I still think I'm missing something...

How do I make the difference between setting the name of
the field
fllname = "[Forms]![0 P/N Summary]!" &_
Format$(countnum, """P/N""00")

and setting the value for the field
fllname = Format$(countnum, """test""00")

countnum = 1
For countnum = 1 To 30
fldname = Format$(countnum, """P/N""00")
fllname = "[Forms]![0 P/N Summary]!" &
Format$(countnum, """P/N""00")
If fllname = Null Then
fllname = Format$(countnum, """test""00")
countnum = 31
Else
countnum = countnum + 1
End If
Next countnum





-----Original Message-----
Katrina,
If fllname = Null Then 'You can't compare to Null this
way, the result will
always be false.
if isnull(fllname) then ' Correct way.

Alex.

I have fields named [P/N01], [P/N02].... to [P/N30]

What I would like to do it have access determine which
field is the first empty field and put some info into it.
I thought that a for loop would work well, so below is the
code I have so far, however it's not quite working. Any
suggestions?

countnum = 1
For countnum = 1 To 30
fldname = Format$(countnum, """P/N""00")
fllname = "[Forms]![0 P/N Summary]!" &
Format$(countnum, """P/N""00")
If fllname = Null Then
fllname = Format$(countnum, """test""00")
countnum = 31
Else
countnum = countnum + 1
End If
Next countnum


.
 
How do I make the difference between setting the name of
the field
fllname = "[Forms]![0 P/N Summary]!" &_
Format$(countnum, """P/N""00")

and setting the value for the field
fllname = Format$(countnum, """test""00")

Well, you could use the Fields colletion

' work out which field to edit
strFieldName = Format$(wCountNum, """P/N""00")

' now set its value
rst.Fields(strFieldName) = Format$(wCountNum, """test""00")


.... or you could try applying some database theory and getting the design
right.


HTH


Tim F
 
Back
Top