473,473 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

"Enter parameter value" input box when running SQL statement

lgo
I have read several variations of this topic posted on this news group.
However I was not able to find the answer for my problem.
I am trying to build code (see below) to update a large single record
using data from a temporary (editing) table with identical field
structure. I iterate through the fields (some 50 of them) with a For
Each - Next loop to update each field with the SQL statement. The
updating works fine with numeric data type but not with text type data.
Each time it tries to update a text data field, I get the following
input box appearing, "Enter parameter value". If I go to the query
design window I can build and run a query based on the same parameters
and update all the fields without any problems (no input box popping
up) regardless of data type. I am wondering why my SQL statement gives
me the pop up and how I can get around it. Is this the best way to
update a record in a table or is there a simpler record global
overwright method that could be used.

Sub subUpDateRec()

Dim db As Database, tbl As Recordset, tbl2 As Recordset, fld As
Field, fld2 As Field,
strFld As String, strValue As String, i As Integer, strCriteria As
String
Set db = CurrentDb
Set tbl = db.OpenRecordset("MyTable")
Set tbl2 = db.OpenRecordset("MyTempTable")
strCriteria = [Forms].[MyForm].[MyControl]
For Each fld In tbl.Fields
strFld = fld.Name
Set fld2 = tbl2.Fields(i)
DoCmd.RunSQL "UPDATE MyTable SET MyTable." & [strFld] & " = " & fld2
& " WHERE (((MyTable.Field)=" & strCriteria & "));"
i = i + 1
Next fld
Set db = Nothing
Set tbl = Nothing

End Sub

(Note: My input form is not bound to the table to be updated.)
I also considered using delete and append methods but the records will
be edited
regularly and I'm afraid the table will become too large and need to be
compacted too often.
(can one never compact often enough!?)

Nov 13 '05 #1
2 14843
lg*@golden.net wrote:
I have read several variations of this topic posted on this news group.
However I was not able to find the answer for my problem.
I am trying to build code (see below) to update a large single record
using data from a temporary (editing) table with identical field
structure. I iterate through the fields (some 50 of them) with a For
Each - Next loop to update each field with the SQL statement. The
updating works fine with numeric data type but not with text type data.
Each time it tries to update a text data field, I get the following
input box appearing, "Enter parameter value". If I go to the query
design window I can build and run a query based on the same parameters
and update all the fields without any problems (no input box popping
up) regardless of data type. I am wondering why my SQL statement gives
me the pop up and how I can get around it. Is this the best way to
update a record in a table or is there a simpler record global
overwright method that could be used.

Sub subUpDateRec()

Dim db As Database, tbl As Recordset, tbl2 As Recordset, fld As
Field, fld2 As Field,
strFld As String, strValue As String, i As Integer, strCriteria As
String
Set db = CurrentDb
Set tbl = db.OpenRecordset("MyTable")
Set tbl2 = db.OpenRecordset("MyTempTable")
strCriteria = [Forms].[MyForm].[MyControl]
For Each fld In tbl.Fields
strFld = fld.Name
Set fld2 = tbl2.Fields(i)
DoCmd.RunSQL "UPDATE MyTable SET MyTable." & [strFld] & " = " & fld2
& " WHERE (((MyTable.Field)=" & strCriteria & "));"
i = i + 1
Next fld
Set db = Nothing
Set tbl = Nothing

End Sub

(Note: My input form is not bound to the table to be updated.)
I also considered using delete and append methods but the records will
be edited
regularly and I'm afraid the table will become too large and need to be
compacted too often.
(can one never compact often enough!?)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

If the data type of fld2 is Text you need to enclose the value w/ single
quotes:

DoCmd.RunSQL "UPDATE MyTable SET MyTable." & [strFld] & " = " & _
IIf(fld2.Type = dbText, "'" & fld2 & "'", fld2) & _
" WHERE ... etc. ...

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQbtG4IechKqOuFEgEQLLZgCdFLFLOsSy4NWx0BNTGpO6Ta VJueMAn1gQ
1OI6pFGkKpONOTtphDtKW/cx
=L+lR
-----END PGP SIGNATURE-----
Nov 13 '05 #2
lgo
Thank you so much! That did it.
I continue to be amazed at all the knowledge out there of all the
nuances of programing in Access and with the people willing to share
their expertise. Without this news group I would have given up long ago
but as it is I am (forever) on the cusp of becoming a POWER
programer.UGH!
Thanks again
Lou

Nov 13 '05 #3

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

Similar topics

4
by: Simon Wigzell | last post by:
Is there a way to prevent a form submitting when you press enter on a text field? Some people press enter when they finish typing in a text field out of habit I guess unconcsciously thinking it...
2
by: lgo | last post by:
I have read several variations of this topic posted on this news group. However I was not able to find the answer for my problem. I am trying to build code (see below) to update a large single...
2
by: Keith | last post by:
I have populated (or created a collection) in a ComboBox. However - I would like to set a default value - when my form is first opened (for the ComboBox) - like "Select topic" However - when I...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
0
by: Bruce | last post by:
It there a way that would allow me to create a cnonce value when using the HttpWebRequest/HttpWebResponse objects for connectivity? If the "WWW-Authenticate" header returns the "qop" I need to be...
6
by: ineedahelp | last post by:
I have been working on trying to get some code to work in an ON CLICK EVENT. I am having trouble with the syntax of an SQL statement. The program was stopped without running to completion many...
1
by: Pieter | last post by:
Hi, Is there a way to link the Hidden-property of a Textbox on a Reporting Services Report to it's Value? When the Value is empty (""), then I want the TextBox be Hidden. In case you don't...
3
by: Simon Verona | last post by:
Sorry for the repost, but this group seems to be more "active" than the group that I posted my question, and it's probably as valid here as there! I have a usercontrol, which contains a textbox...
7
by: adigga1 | last post by:
Hello EveryOne, I have a situation with a Form running an event; It works fine when it calls or manipulates number values; but when I put a character within the numbers or use alpha-numeric...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
1
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: 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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.