D
DavidC
Hi,
I have a code, below, which returns records stored in a
vertical database to a horizontal. IE Each refid could
have a number of records each with a different value
associated with the custref . Some may not have the same
combination of custref. The code seems to work generally
well but I have noticed that it does not write all the
records to the database. In fact using a crosstab query
there is a difference of 720 records out of 3886 records
between the two. The problem is that I cannot use the
crosstab query as the custref may or may not appear in the
database, so the query cannot include every possible
custref in it as if the custref does not appear in the
database then it goes into error. I have only reproduced
two out of the 13 possible instances of custref. The
database is a linked database hence the reason that some
databases that it links to may or may not have the same
combination of custref.
I cannot figure out why some records are returned byu the
code correctly yet there are the 700 that are not
returned. When I use the debug feature, the values for
the missing records are recorded in the variables and it
runs through the .addnew to .update and the varioabels
contain the right values, but the database does not have
them written in.
Any thoughts would be appreciated.
CODE
Set db = DBEngine.Workspaces(0)(0) 'CurrentDb()
Set rsqt = db.OpenRecordset("qrytext_fields",
dbOpenDynaset)
Do Until rsqt.EOF = True
unid1 = rsqt!refid
If IsNull(rsqt!txt_value) Then
custdesc = ""
Else
custdesc = rsqt!txt_value
End If
custref = rsqt!txt_id
Select Case custref
Case 188
jdescrip = custdesc
Case 1889
custwo = custdesc
End Select
rsqt.MoveNext
unid2 = rsqt!refid
If unid1 = unid2 Then
Else
Set rsc = db.OpenRecordset("tblcustom_fields",
dbOpenDynaset)
With rsc
.AddNew
!UID = unid1
!Work_Order = custwo
!Job_Description = jdescrip
.Update
End With
custwo = ""
jdescrip = ""
End If
Loop
Thanks in advance of any help
regards
DavidC
I have a code, below, which returns records stored in a
vertical database to a horizontal. IE Each refid could
have a number of records each with a different value
associated with the custref . Some may not have the same
combination of custref. The code seems to work generally
well but I have noticed that it does not write all the
records to the database. In fact using a crosstab query
there is a difference of 720 records out of 3886 records
between the two. The problem is that I cannot use the
crosstab query as the custref may or may not appear in the
database, so the query cannot include every possible
custref in it as if the custref does not appear in the
database then it goes into error. I have only reproduced
two out of the 13 possible instances of custref. The
database is a linked database hence the reason that some
databases that it links to may or may not have the same
combination of custref.
I cannot figure out why some records are returned byu the
code correctly yet there are the 700 that are not
returned. When I use the debug feature, the values for
the missing records are recorded in the variables and it
runs through the .addnew to .update and the varioabels
contain the right values, but the database does not have
them written in.
Any thoughts would be appreciated.
CODE
Set db = DBEngine.Workspaces(0)(0) 'CurrentDb()
Set rsqt = db.OpenRecordset("qrytext_fields",
dbOpenDynaset)
Do Until rsqt.EOF = True
unid1 = rsqt!refid
If IsNull(rsqt!txt_value) Then
custdesc = ""
Else
custdesc = rsqt!txt_value
End If
custref = rsqt!txt_id
Select Case custref
Case 188
jdescrip = custdesc
Case 1889
custwo = custdesc
End Select
rsqt.MoveNext
unid2 = rsqt!refid
If unid1 = unid2 Then
Else
Set rsc = db.OpenRecordset("tblcustom_fields",
dbOpenDynaset)
With rsc
.AddNew
!UID = unid1
!Work_Order = custwo
!Job_Description = jdescrip
.Update
End With
custwo = ""
jdescrip = ""
End If
Loop
Thanks in advance of any help
regards
DavidC