473,416 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

ADOX error

Hello Experts outhere,

may be someone can tell me whats going wrong with my ADOX trial.
I have an Access 2002 database with some tables and queries (views)

The code listed below works well up to the point where I want to add
the new view to the views collection. I get Runtime error 3001 which
is telling me
"Arguments are of wrong type,are out of acceptable range or conflict
with one another"
I should metion that the table I'm refering is a LINKED one (DB is
also an access 2002 db on the same machine). But I don't expect any
impact by that.

The listing of the views alreay existing (debug.print) works well,
menas the cnn1 and cat1 objects ar probaly OK.

Any idea is welcome

Rolf

Private Sub Command41_Click()

Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim cat1 As ADOX.Catalog
Dim v As ADOX.View
Set cnn1 = New ADODB.Connection
Set cmd1 = New ADODB.Command
Set cat1 = New ADOX.Catalog

Set cmd1.ActiveConnection = CurrentProject.Connection
Debug.Print CurrentProject.Connection ' OK
'cmd1.CommandType = adCmdText
cmd1.CommandText = "SELECT * FROM CallRecords_tab"

Set cat1.ActiveConnection = CurrentProject.Connection

For Each v In cat1.Views
Debug.Print v.Name ' OK
Next

cat1.Views.Append "NewView", cmd1 ' error 3001 !!

For Each v In cat1.Views
Debug.Print v.Name
Next

End Sub
Nov 12 '05 #1
3 10126
The only thing you are doing differently from what I would is setting the
ActiveConnection of the command object to something other than the instance
of the catalog you have declared. Try:

Private Sub Command41_Click()
Dim cat1 As ADOX.Catalog
Dim cmd1 As ADODB.Command

Set cat1 = New ADOX.Catalog
Set cmd1 = New ADODB.Command

Set cat1.ActiveConnection = CurrentProject.Connection
cmd1.CommandText = "SELECT * FROM CallRecords_tab;"

cat1.Views.Append "NewView", cmd1
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"KemperR" <Ke*****@t-online.de> wrote in message
news:90**************************@posting.google.c om...
Hello Experts outhere,

may be someone can tell me whats going wrong with my ADOX trial.
I have an Access 2002 database with some tables and queries (views)

The code listed below works well up to the point where I want to add
the new view to the views collection. I get Runtime error 3001 which
is telling me
"Arguments are of wrong type,are out of acceptable range or conflict
with one another"
I should metion that the table I'm refering is a LINKED one (DB is
also an access 2002 db on the same machine). But I don't expect any
impact by that.

The listing of the views alreay existing (debug.print) works well,
menas the cnn1 and cat1 objects ar probaly OK.

Any idea is welcome

Rolf

Private Sub Command41_Click()

Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim cat1 As ADOX.Catalog
Dim v As ADOX.View
Set cnn1 = New ADODB.Connection
Set cmd1 = New ADODB.Command
Set cat1 = New ADOX.Catalog

Set cmd1.ActiveConnection = CurrentProject.Connection
Debug.Print CurrentProject.Connection ' OK
'cmd1.CommandType = adCmdText
cmd1.CommandText = "SELECT * FROM CallRecords_tab"

Set cat1.ActiveConnection = CurrentProject.Connection

For Each v In cat1.Views
Debug.Print v.Name ' OK
Next

cat1.Views.Append "NewView", cmd1 ' error 3001 !!

For Each v In cat1.Views
Debug.Print v.Name
Next

End Sub

Nov 12 '05 #2
Allen,
thanks a lot for the tip. Its working now! But this leads to a very
general question for me.
Imagine I have a shared DB or the DB is on a server and will be
instanciated several times.

In my undestanding the newly created view is visble to all users.

In case the name of the view is always the same and just the cmd
string will change entries can be overwritten by the users which are
loged in on the same access db.

Can I create private views in memory or such things ?

My target is to create some SQL statement execute it and present it to
the user like opening an existing query.

Ok, I can execute a command and assign the result to a recordset. But
how to make the recordset visible like running a query. Creating a
dynamic form with all the fields seams to be a big task. Or is there
some approch to do that in an easy way?
What is the best way to achieve that functionality ?
Thanks a lot for your help

Rolf

"Allen Browne" <ab***************@bigpond.net.au> wrote in message news:<P6*******************@news-server.bigpond.net.au>...
The only thing you are doing differently from what I would is setting the
ActiveConnection of the command object to something other than the instance
of the catalog you have declared. Try:

Private Sub Command41_Click()
Dim cat1 As ADOX.Catalog
Dim cmd1 As ADODB.Command

Set cat1 = New ADOX.Catalog
Set cmd1 = New ADODB.Command

Set cat1.ActiveConnection = CurrentProject.Connection
cmd1.CommandText = "SELECT * FROM CallRecords_tab;"

cat1.Views.Append "NewView", cmd1
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"KemperR" <Ke*****@t-online.de> wrote in message
news:90**************************@posting.google.c om...
Hello Experts outhere,

may be someone can tell me whats going wrong with my ADOX trial.
I have an Access 2002 database with some tables and queries (views)

The code listed below works well up to the point where I want to add
the new view to the views collection. I get Runtime error 3001 which
is telling me
"Arguments are of wrong type,are out of acceptable range or conflict
with one another"
I should metion that the table I'm refering is a LINKED one (DB is
also an access 2002 db on the same machine). But I don't expect any
impact by that.

The listing of the views alreay existing (debug.print) works well,
menas the cnn1 and cat1 objects ar probaly OK.

Any idea is welcome

Rolf

Private Sub Command41_Click()

Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim cat1 As ADOX.Catalog
Dim v As ADOX.View
Set cnn1 = New ADODB.Connection
Set cmd1 = New ADODB.Command
Set cat1 = New ADOX.Catalog

Set cmd1.ActiveConnection = CurrentProject.Connection
Debug.Print CurrentProject.Connection ' OK
'cmd1.CommandType = adCmdText
cmd1.CommandText = "SELECT * FROM CallRecords_tab"

Set cat1.ActiveConnection = CurrentProject.Connection

For Each v In cat1.Views
Debug.Print v.Name ' OK
Next

cat1.Views.Append "NewView", cmd1 ' error 3001 !!

For Each v In cat1.Views
Debug.Print v.Name
Next

End Sub

Nov 12 '05 #3
Are you aware of the technique of splitting a database into back end (tables
only) and front end (separate mdb file containing the queries, form,
reports, and code, and linked tables)?

Each user gets their own copy of the front end, so you can do whatever you
like: the objects (including views) are completely independent of other
users.

Personally I do not permit the user to open tables and queries/view
directly. Forms are the appropriate interface. A form in Datasheet view
looks the same kind of interface as a query, but gives you much more control
(through the events). You can assign any SQL statement directly to the
RecordSource of the form and you don't need to create a view.

It is also possible to assign a recordset to the form, but I don't see the
advantage in that for the case you describe.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"KemperR" <Ke*****@t-online.de> wrote in message
news:90**************************@posting.google.c om...
Allen,
thanks a lot for the tip. Its working now! But this leads to a very
general question for me.
Imagine I have a shared DB or the DB is on a server and will be
instanciated several times.

In my undestanding the newly created view is visble to all users.

In case the name of the view is always the same and just the cmd
string will change entries can be overwritten by the users which are
loged in on the same access db.

Can I create private views in memory or such things ?

My target is to create some SQL statement execute it and present it to
the user like opening an existing query.

Ok, I can execute a command and assign the result to a recordset. But
how to make the recordset visible like running a query. Creating a
dynamic form with all the fields seams to be a big task. Or is there
some approch to do that in an easy way?
What is the best way to achieve that functionality ?
Thanks a lot for your help

Rolf

"Allen Browne" <ab***************@bigpond.net.au> wrote in message

news:<P6*******************@news-server.bigpond.net.au>...
The only thing you are doing differently from what I would is setting the ActiveConnection of the command object to something other than the instance of the catalog you have declared. Try:

Private Sub Command41_Click()
Dim cat1 As ADOX.Catalog
Dim cmd1 As ADODB.Command

Set cat1 = New ADOX.Catalog
Set cmd1 = New ADODB.Command

Set cat1.ActiveConnection = CurrentProject.Connection
cmd1.CommandText = "SELECT * FROM CallRecords_tab;"

cat1.Views.Append "NewView", cmd1
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html

"KemperR" <Ke*****@t-online.de> wrote in message
news:90**************************@posting.google.c om...
Hello Experts outhere,

may be someone can tell me whats going wrong with my ADOX trial.
I have an Access 2002 database with some tables and queries (views)

The code listed below works well up to the point where I want to add
the new view to the views collection. I get Runtime error 3001 which
is telling me
"Arguments are of wrong type,are out of acceptable range or conflict
with one another"
I should metion that the table I'm refering is a LINKED one (DB is
also an access 2002 db on the same machine). But I don't expect any
impact by that.

The listing of the views alreay existing (debug.print) works well,
menas the cnn1 and cat1 objects ar probaly OK.

Any idea is welcome

Rolf

Private Sub Command41_Click()

Dim cnn1 As ADODB.Connection
Dim cmd1 As ADODB.Command
Dim cat1 As ADOX.Catalog
Dim v As ADOX.View
Set cnn1 = New ADODB.Connection
Set cmd1 = New ADODB.Command
Set cat1 = New ADOX.Catalog

Set cmd1.ActiveConnection = CurrentProject.Connection
Debug.Print CurrentProject.Connection ' OK
'cmd1.CommandType = adCmdText
cmd1.CommandText = "SELECT * FROM CallRecords_tab"

Set cat1.ActiveConnection = CurrentProject.Connection

For Each v In cat1.Views
Debug.Print v.Name ' OK
Next

cat1.Views.Append "NewView", cmd1 ' error 3001 !!

For Each v In cat1.Views
Debug.Print v.Name
Next

End Sub

Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: TJS | last post by:
can't seem to get this ADOX code to add columns to existing Access 2000 table what's missing ? Sub AddTableFields() Set tbl = Server.CreateObject("ADOX.Table") set cat =...
2
by: Randy | last post by:
I am trying to relink some Oracle tables in an Access database via VB.NET and ADOX. I receive the following error when executing the cat.ActiveConnection link "Arguments are of the wrong type,...
5
by: Wayne Wengert | last post by:
I am getting an error that "object no longer valid" at the point indicated in the code below - I am trying to build a table in an Access 2000 database using ADOX. Any thoughts on what might cause...
6
by: Michael | last post by:
I am trying to create an access database within Net 2003 using the ADOX library which works fine except when I try to add the AutoIncrement property to the ContactId column. I am experiencing a...
2
by: genojoe | last post by:
Using ADOX to update a Property does not work. I want to change the Access database for a linked table. My abridged code is: Dim oCAT As ADOX.Catalog oCAT = New ADOX.Catalog...
3
by: Miro | last post by:
Something weird I have run into when trying to add a boolean field to an Access table by code. -Just wondering if anyone else has run into this. ( vb.net 2005 express ) If I add any other...
4
devonknows
by: devonknows | last post by:
Hi can any one please help me with creating a secure database with ADO or ADOX if possible, ive got this code already but its not accessible through VisData so i cant easily modify it at all. ...
0
parshupooja
by: parshupooja | last post by:
Hey all, I have Arraylist where I have stored names of Tables.I have two datasources one is SQL and one is Access, they have equal number of tabels. I am trying to find Access databse column and...
2
by: mouac01 | last post by:
I can't set the field description property with the code below. I get the error "Item cannot be found in the collection corresponding to the requested name or ordinal". Any ideas. TIA... Sub...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.