adding records (1 Viewer)

dgoulston

Hasn't Got A Clue
Local time
Today, 03:41
Joined
Jun 10, 2002
Messages
403
hay ok here is the problem

#############################
If bit(0) Then
With rst
.Edit
![0] = "X"
.Update
End With
End If


##########################
and i do this for bit(0) through to bit(20), the colomn names are o through to 20
is there a way to do it like:
#########################
dim n as integer
for n = 0 to 20
If bit(n) = true Then
With rst
.Edit
![n] = "X"
.Update
End With
End If
next n
#######################
i have tried it like above and it does not let you use a varible as the colomn name.



is there a way that it will let me?

thanks
DAL
 

Fizzio

Chief Torturer
Local time
Today, 03:41
Joined
Feb 21, 2002
Messages
1,885
To start with , it is not ideal practice to use sequential numbers for field names - I think mainly as it tells you nothing but I'm sure Pat will know a better reason;)

To use variables in a recordset use

dim n as integer
for n = 0 to 20
If bit(n) = true Then 'But what is bit? - is it an array?
With rst
.Edit
!(n) = "X" ' You can use ![Fieldname] or ("Fieldname") in a rst
.Update
End With
End If
next n
 

dgoulston

Hasn't Got A Clue
Local time
Today, 03:41
Joined
Jun 10, 2002
Messages
403
i tried using this:
########################
dim i as int
For i = 0 To 8
FBmsg = ""
If bit(i) Then
With rst
.Edit
!(i) = "X"
.Update
End With
End If
End If

##########################
and it came up with the error "expected identifier or bracketed expression" on the line !(i) = "x"


why is this?

the field names 1-20 mean a lot to me.

DAL

p.s. bit() is an array.
 
Last edited:

dgoulston

Hasn't Got A Clue
Local time
Today, 03:41
Joined
Jun 10, 2002
Messages
403
ok solved it!


########################
dim i as integer
For i = 0 To 8
FBmsg = ""
If bit(i) Then
With rst
.Edit
Fields(i) = "X"
.Update
End With
End If
End If

#########################
had to use the word fields rather than the .

DAL
 

Users who are viewing this thread

Top Bottom