incagold
Programmer
- Mar 21, 2003
- 54
Hi guys,
Newbie here again. I have a problem with being able to use a table I just created via code (visual basic, SQL statement and ado). When I try to open this table to use the records that were just inserted, I get an error message that the table is not found. When I look at the database (access2000) the table is there. Is there something like a refresh that must be done in vb or ado that will allow immediate use of the new table?
Here is the portion of code that fails:
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM Default_LineItemLayout;", cn, _
adOpenDynamic, adLockPessimistic
strSQL = "INSERT INTO " & strTBL1 & " "
strSQL = strSQL & "( [Record code], [Schedule reference number], "
strSQL = strSQL & "[Line item number], [Line item description], "
strSQL = strSQL & "[CA/GF], [Condition code] "
strSQL = strSQL & "FROM Default_LineItemLayout, " & strTBL2 & ";"
DoCmd.RunSQL strSQL
rs.Close
Set rs = Nothing
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM " & strTBL1 & ";", cn, _
adOpenDynamic, adLockPessimistic
'*** Establish serialized line item number
Dim lngLINum As Long
lngLINum = 1
rs.MoveFirst
Do While Not rs.EOF
With rs
If lngLINum >= 100 And lngLINum < 1000 Then
![Line item number] = "0" & Trim(Str(lngLINum))
ElseIf lngLINum >= 10 And lngLINum < 100 Then
![Line item number] = "00" & Trim(Str(lngLINum))
ElseIf lngLINum > 0 And lngLINum < 10 Then
![Line item number] = "000" & Trim(Str(lngLINum))
End If
.Update
End With
lngLINum = lngLINum + 1
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
strTBL1 and strTBL2 sre variables passed to the SQL statement
If I try and run an update (above) against the table just created here, the error that the table is not available displays.
Thanks in advance for your help. It is always sincerely appreciated.
BEF
Newbie here again. I have a problem with being able to use a table I just created via code (visual basic, SQL statement and ado). When I try to open this table to use the records that were just inserted, I get an error message that the table is not found. When I look at the database (access2000) the table is there. Is there something like a refresh that must be done in vb or ado that will allow immediate use of the new table?
Here is the portion of code that fails:
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM Default_LineItemLayout;", cn, _
adOpenDynamic, adLockPessimistic
strSQL = "INSERT INTO " & strTBL1 & " "
strSQL = strSQL & "( [Record code], [Schedule reference number], "
strSQL = strSQL & "[Line item number], [Line item description], "
strSQL = strSQL & "[CA/GF], [Condition code] "
strSQL = strSQL & "FROM Default_LineItemLayout, " & strTBL2 & ";"
DoCmd.RunSQL strSQL
rs.Close
Set rs = Nothing
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM " & strTBL1 & ";", cn, _
adOpenDynamic, adLockPessimistic
'*** Establish serialized line item number
Dim lngLINum As Long
lngLINum = 1
rs.MoveFirst
Do While Not rs.EOF
With rs
If lngLINum >= 100 And lngLINum < 1000 Then
![Line item number] = "0" & Trim(Str(lngLINum))
ElseIf lngLINum >= 10 And lngLINum < 100 Then
![Line item number] = "00" & Trim(Str(lngLINum))
ElseIf lngLINum > 0 And lngLINum < 10 Then
![Line item number] = "000" & Trim(Str(lngLINum))
End If
.Update
End With
lngLINum = lngLINum + 1
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
strTBL1 and strTBL2 sre variables passed to the SQL statement
If I try and run an update (above) against the table just created here, the error that the table is not available displays.
Thanks in advance for your help. It is always sincerely appreciated.
BEF