473,809 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Required Parameters for a command object

Hi, my simple solution is not so simple. I have done a bit of VB
programming, and am now tasked with trying to make access work using
VBA, and battling my butt off. This probably has a really simple
solution, which right now eludes me.

The code is below, and the error message I get is this "No Value given
for one or more required parameters". sClinic is picking up the string
from a combo box, and this does work cos the message box tosses out
the right value.

Private Sub cmdUpdateReport _Click()
On Error GoTo Err_cmdUpdateRe port_Click

Dim stDocName As String
Dim AppCmd1 As ADODB.Command

stDocName = "Macro1"
DoCmd.RunMacro stDocName

On Error GoTo Err_cmdUpdateRe port_Click

Set AppCmd1 = New ADODB.Command
AppCmd1.ActiveC onnection = CurrentProject. Connection
AppCmd1.Command Type = adCmdText
AppCmd1.Command Text = _
"INSERT INTO New_Complete_Da ta (Facility_Code, ColA, ColB,
ColC, ColD, ColE, ColF, ColG, ColH, ColI, ColJ, ColK, ColL, ColM,
ColN, ColO, ColP, ColQ, ColR)" & _
"SELECT M1C.Facility_Co de AS Facility_Code, M1C.C11 AS ColA,
M1C.C12 AS ColB, M1C.C14 AS ColC, M1C.C32, M1C.C43, M1C.C51, M1C.C52,
M1C.C53, M1C.C61, M1C.C71, M1C.C72 AS ColK, M1C.SumDenC16 AS ColL,
M1C.SumC16 AS ColM, M1C.SumDenC82 AS ColN, M1C.SumC82 AS ColO, M1C.C84
AS ColP, M1C.C91 AS ColQ, M1C.C102 " & _
"FROM M1C WHERE M1C.Facility_Co de = " & sClinic & " "
MsgBox ("The current clinic code is " & sClinic & ""), vbOKOnly

AppCmd1.Execute

Set AppCmd1 = Nothing

Exit_cmdUpdateR eport_Click:
Exit Sub

Err_cmdUpdateRe port_Click:
MsgBox Err.Description
Resume Exit_cmdUpdateR eport_Click

End Sub

I really appreciate the help.
Jenni
Nov 12 '05 #1
3 4757
"Jenni" <jr*******@khul isa.com> wrote in message
news:db******** *************** **@posting.goog le.com...
Hi, my simple solution is not so simple. I have done a bit of VB
programming, and am now tasked with trying to make access work using
VBA, and battling my butt off. This probably has a really simple
solution, which right now eludes me.

The code is below, and the error message I get is this "No Value given
for one or more required parameters". sClinic is picking up the string
from a combo box, and this does work cos the message box tosses out
the right value.

Private Sub cmdUpdateReport _Click()
On Error GoTo Err_cmdUpdateRe port_Click

Dim stDocName As String
Dim AppCmd1 As ADODB.Command

stDocName = "Macro1"
DoCmd.RunMacro stDocName

On Error GoTo Err_cmdUpdateRe port_Click

Set AppCmd1 = New ADODB.Command
AppCmd1.ActiveC onnection = CurrentProject. Connection
AppCmd1.Command Type = adCmdText
AppCmd1.Command Text = _
"INSERT INTO New_Complete_Da ta (Facility_Code, ColA, ColB,
ColC, ColD, ColE, ColF, ColG, ColH, ColI, ColJ, ColK, ColL, ColM,
ColN, ColO, ColP, ColQ, ColR)" & _
"SELECT M1C.Facility_Co de AS Facility_Code, M1C.C11 AS ColA,
M1C.C12 AS ColB, M1C.C14 AS ColC, M1C.C32, M1C.C43, M1C.C51, M1C.C52,
M1C.C53, M1C.C61, M1C.C71, M1C.C72 AS ColK, M1C.SumDenC16 AS ColL,
M1C.SumC16 AS ColM, M1C.SumDenC82 AS ColN, M1C.SumC82 AS ColO, M1C.C84
AS ColP, M1C.C91 AS ColQ, M1C.C102 " & _
"FROM M1C WHERE M1C.Facility_Co de = " & sClinic & " "
MsgBox ("The current clinic code is " & sClinic & ""), vbOKOnly

AppCmd1.Execute

Set AppCmd1 = Nothing

Exit_cmdUpdateR eport_Click:
Exit Sub

Err_cmdUpdateRe port_Click:
MsgBox Err.Description
Resume Exit_cmdUpdateR eport_Click

End Sub

I really appreciate the help.
Jenni


1) If this code is failing, why not replace the line AppCmd1.Execute with
Debug.Print AppCmd1.Command Text temporarily so that you can see the SQL
string which it is trying to execute.

2) This should turn up a missing space here ...ColR)SELECT M1C.Facility_Co de
AS...

3) There are also no quotes for the string value WHERE M1C.Facility_Co de =
MyClinic instead of WHERE M1C.Facility_Co de = "MyClinic"

4) Why is sClinic not dimmed? Please don't say you do not use "Option
Explicit"

5) Other, less important points follow:

**Error Handling:
Why is "On Error GoTo Err_cmdUpdateRe port_Click" in there twice?

Why don't you label your error handlers with more standard names? Did you
get a wizard to write the code? Wouldn't "On Error GoTo Err_Handler" be
easier than "On Error GoTo Err_cmdUpdateRe port_Click"? Not only is it more
readable, but more transferable and less weird if you rename controls - I
would write it like this:

Private Sub cmdUpdateReport _Click()

On Error GoTo Err_Handler

MsgBox "Hi"

Exit_Handler:
Exit Sub

Err_Handler:
MsgBox Err.Description , vbExclamation, "Error No: " & Err.Number
Resume Exit_Handler

End Sub
**Object library
Any special reason you are using ADO code rather than DAO?
** Macros?
DoCmd.RunMacro stDocName
Not many people here use macros - they are simply too limiting

Nov 12 '05 #2
Jenni,
looks like you forgot to put quotes around your variable... I think this line:
"FROM M1C WHERE M1C.Facility_Co de = " & sClinic & " "
should be "FROM M1C WHERE M1C.Facility_Co de = '" & sClinic & "' "


so when the select statement compiles, it looks like this:

....FROM MIC WHERE M1C.Facility_Co de = 'Some Value'

Try that and see if that fixes it.
Nov 12 '05 #3
The string problem solution makes it work, Thanks a million. In
response to the other questions though

1. sClinnic is dimmed as a Private variable at the form level cos it
is picked up in the Lost_Focus event of the combo box.

2. The space thing is not a problem

3. Didn't try the debug.print thing, but will keep it in mind for
future use.

4. Yes a wizard wrote the initial code. I'm new at this, so the wizard
makes it a little easier for me.

5. I use the macro's as it is an inherited project and the macro's do
90% of the work already.

Thanks again. You folks are an absolute fountain of knowledge and
inspiration. I hope I can someone else sometime.

pi********@hotm ail.com (Pieter Linden) wrote in message news:<bf******* *************** ****@posting.go ogle.com>...
Jenni,
looks like you forgot to put quotes around your variable... I think this line:
"FROM M1C WHERE M1C.Facility_Co de = " & sClinic & " "


should be
"FROM M1C WHERE M1C.Facility_Co de = '" & sClinic & "' "


so when the select statement compiles, it looks like this:

...FROM MIC WHERE M1C.Facility_Co de = 'Some Value'

Try that and see if that fixes it.

Nov 12 '05 #4

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

Similar topics

5
4382
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm stuck here.
1
9501
by: PinkGuava | last post by:
Hi, I have a T-SQL stored procedure that returns both output parameters and a recordset. How do I retrieve them in my ASP script? As far as I know, the ADO Command object can be used to retrieve the output parameters, but will I be able to retrieve the recordset using the Command object as well? Or do I have to use the Recordset object? Example of stored procedure:
6
464
by: Derek | last post by:
I have an aspx page where I use a reversebind and templates to edit the entire datagrid at one time. I added a textbox and button to change the parameter criteria and then rerun the databind2 procedure. That works fine the data is requeried and the new results are displayed in the datagrid and the reversebind works for saving the information. However if I add another text box or dropdown box it does not seem to requery correctly. If...
15
2893
by: Fred Zwarts | last post by:
In C++ execution of a program starts already before execution of main(). The initialization of static variables defined outside the scope of main is performed first. I could imagine a program where the whole job can be done in the constructor and destructor of a static variable. (Wouldn't that be the ultimate OOP program, just the creation and deletion of an object?) Does the C++ standard require to have a (dummy) main() function in such...
7
21643
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or PostgreSQL using ADO ? Is it possible to execute pass-through queries with parameters, using ADO...
3
8843
by: Brian Foree | last post by:
I am developing an ASP.NET application that uses Access 2000 as its backend, and have just started getting the following error on 2 ASP.NET pages that had been working until late last week (and I don't think I made any changes to either page other than changing the user control that creates the header). Server Error in '/myApp' Application. ---------------------------------------------------------------------------- ----
5
4482
by: Martin Bischoff | last post by:
Hi, is it possible to modify the values of a SqlDataSource's select parameters in the code behind before the select command is executed? Example: I have an SqlDataSource with a ControlParameter <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:XYZ %>"
6
6529
by: BlackMustard | last post by:
hi all, i get a run-time error '424': Object Required on the last line below, and i can't figure out why... Dim adoConn As New ADODB.Connection Dim adoCmd As New ADODB.Command Dim adoRecSet As New ADODB.Recordset ' "SELECT dbDescription,dbExternal FROM EuroPrice WHERE dbFAB = '" & Format(txtFAB.Text, "@@@ @@@ @@@@") & "'"
0
4615
by: AxleWacl | last post by:
Hi, The below error is what I am receiving. The code im using is below the error, for the life of me, I can not see where any parameter is missing..... Server Error in '/FleetcubeNews' Application. -------------------------------------------------------------------------------- No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please...
0
10637
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10379
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.