View is not useable after Appending (Access, ADOX, VB)
Posted on 2001-06-20
Running Win '98, Access 97, VB
I'm using the included Function to create views.
After creating a view, I open Access and check it out.
It look ok, but reports an error when executed.
After touching the SQL (inserting a blank, replacing an 'a' by an 'a') the view works perfect. ?
Normal views can be access by the following code, but not the view created by the function I include.
dim ViewSql as string
Set DBcmd = dbcat.Views(ViewName).Command
ViewSQL = Trim(DBcmd.CommandText)
Can anybody help?
Am I missing a Property somewhere?
Private Function ViewCreate(ViewName As String, ViewSQL As String) As Boolean
Dim dbcat As ADOX.Catalog
Dim DBcmd As ADODB.Command
' create view (xxx)
ViewCreate = False
On Error GoTo ErrorHandling
Set dbcat = New ADOX.Catalog
Set dbcat.ActiveConnection = ConnectionString
Set DBcmd = New ADODB.Command
DBcmd.CommandText = ViewSQL
dbcat.Views.Append ViewName, DBcmd
Set dbcat = Nothing
Set DBcmd = Nothing
ViewCreate = True
MsgBox ERR.Number & " " & ERR.Description