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. |
|
|
|
Thread Tools | Display Modes |
#11
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|