A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Limit to List - Set to No, Problem



 
 
Thread Tools Display Modes
  #11  
Old September 12th, 2008, 05:57 PM posted to microsoft.public.access
Ken Sheridan
external usenet poster
 
Posts: 3,433
Default cmd As ADODB.Command

You are quite right about the need for a reference, to the Microsoft ActiveX
Data Objects Library in this case. The library is referenced as ADODB.

Or DAO could be used:

Dim dbs AS DAO.Database
Dim ctrl As Control
Dim strSQL As String, strMessage As String

Set dbs = CurrentDb
Set ctrl = Me.ActiveControl
strMessage = "Add new city to list?"

strSQL = "INSERT INTO Cities(City) VALUES(""" & _
NewData & """)"

If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
dbs.Execute strSQL
Response = acDataErrAdded
Else
Response = acDataErrContinue
ctrl.Undo
End If

Ken Sheridan
Stafford, England

"Larry Linson" wrote:

In a module window, Tools | References, and be sure the reference for
Microsoft ADO is checked. Should it be ADO.Command rather than
ADODB.Command?

Larry Linson
Microsoft Office Access MVP

Bill wrote in message ...
I'm trying to give your code snippet a try but Access isn't liking "Dim
cmd As ADODB.Command"

All along so far all I've had to use is db = database and set that too
CurrentDb() in order to run and execute queries. How would I modify this
snippet to work with my set up?? Or what am I missing?

Thank in advanced.








  #12  
Old September 12th, 2008, 06:13 PM posted to microsoft.public.access
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default cmd As ADODB.Command

Since virtually all machines these days are going to have ADO installed on
them, another option would be to use Late Binding, so that no reference is
required. Of course, you then need to provide the values for any ADO
constants you might be using.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"Ken Sheridan" wrote in message
...
You are quite right about the need for a reference, to the Microsoft
ActiveX
Data Objects Library in this case. The library is referenced as ADODB.

Or DAO could be used:

Dim dbs AS DAO.Database
Dim ctrl As Control
Dim strSQL As String, strMessage As String

Set dbs = CurrentDb
Set ctrl = Me.ActiveControl
strMessage = "Add new city to list?"

strSQL = "INSERT INTO Cities(City) VALUES(""" & _
NewData & """)"

If MsgBox(strMessage, vbYesNo + vbQuestion) = vbYes Then
dbs.Execute strSQL
Response = acDataErrAdded
Else
Response = acDataErrContinue
ctrl.Undo
End If

Ken Sheridan
Stafford, England

"Larry Linson" wrote:

In a module window, Tools | References, and be sure the reference for
Microsoft ADO is checked. Should it be ADO.Command rather than
ADODB.Command?

Larry Linson
Microsoft Office Access MVP

Bill wrote in message ...
I'm trying to give your code snippet a try but Access isn't liking "Dim
cmd As ADODB.Command"

All along so far all I've had to use is db = database and set that too
CurrentDb() in order to run and execute queries. How would I modify
this
snippet to work with my set up?? Or what am I missing?

Thank in advanced.










  #13  
Old September 13th, 2008, 04:40 AM posted to microsoft.public.access
David W. Fenton
external usenet poster
 
Posts: 3,373
Default cmd As ADODB.Command

Bill wrote in :

I'm trying to give your code snippet a try but Access isn't liking
"Dim cmd As ADODB.Command"


What makes you think you need ADO in the first place?

All along so far all I've had to use is db = database and set that
too CurrentDb() in order to run and execute queries. How would I
modify this snippet to work with my set up?? Or what am I
missing?


CurrentDB is a function/method provided in two places in the Access
object hierarchy, under Application and under DAO. If you're using
CurrentDB then you shouldn't be mixing in ADO.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
  #14  
Old September 13th, 2008, 04:43 AM posted to microsoft.public.access
David W. Fenton
external usenet poster
 
Posts: 3,373
Default cmd As ADODB.Command

"Douglas J. Steele" wrote in
:

Since virtually all machines these days are going to have ADO
installed on them,


But every machine without exception that has Access installed has
DAO, so why bother with ADO?

another option would be to use Late Binding, so that no reference
is required. Of course, you then need to provide the values for
any ADO constants you might be using.


Why use ADO in the first place? There are fewer than a half dozen
things that ADO provides that DAO lacks.

--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:27 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.