Andy (Andrzejek) and I have been working on an MS Access issue for about a week now. VBA code inspecting the .ldb file for the computer_name of who's on line. We have that part down. Now we need to insert the results into a table. We are using strSQL to do this and we keep coming up with a Syntax error. See the therad named Adding VBA results to table for a list of things we have tried. Here is the code:
Function ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long
Dim dbs As Database
Set cn = CurrentProject.Connection
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
'Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
'"", rs.Fields(2).Name, rs.Fields(3).Name
' Modify this line to include the path and name
' to your Access data base
Set dbs = OpenDatabase("C:\Documents and Settings\xjjs8542\Desktop\ED\DB\Working\Test ED Rev 1.X.mdb")
'While Not rs.EOF
'strSQL = "INSERT INTO Usertbl (ComputerName) " _
' & " VALUES('" & Trim(rs.Fields(0)) & "')"
'Debug.Print strSQL
'dbs.Execute strSQL 'Code fails here indicatgingstrSQL
syntax error
'rs.MoveNext
'Wend
Debug.Print rs.Fields(0)
dbs.Close
End Function
I have validate the Table Name and Field name to be spelled correctly...you can see where I indicated the Code Failure.
Can anyone help...please.
Function ShowUserRosterMultipleUsers()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim i, j As Long
Dim dbs As Database
Set cn = CurrentProject.Connection
Set rs = cn.OpenSchema(adSchemaProviderSpecific, _
, "{947bb102-5d43-11d1-bdbf-00c04fb92675}")
'Debug.Print rs.Fields(0).Name, "", rs.Fields(1).Name, _
'"", rs.Fields(2).Name, rs.Fields(3).Name
' Modify this line to include the path and name
' to your Access data base
Set dbs = OpenDatabase("C:\Documents and Settings\xjjs8542\Desktop\ED\DB\Working\Test ED Rev 1.X.mdb")
'While Not rs.EOF
'strSQL = "INSERT INTO Usertbl (ComputerName) " _
' & " VALUES('" & Trim(rs.Fields(0)) & "')"
'Debug.Print strSQL
'dbs.Execute strSQL 'Code fails here indicatgingstrSQL
syntax error
'rs.MoveNext
'Wend
Debug.Print rs.Fields(0)
dbs.Close
End Function
I have validate the Table Name and Field name to be spelled correctly...you can see where I indicated the Code Failure.
Can anyone help...please.