 | 
28-Jul-2006, 08:00 AM
|  | Guest | | | | | | | | | | A Debug Challenge... Okay. This one has got me. Maybe someone, here, can offer another
suggestion...
Here's the code:
Dim Visit1 as String
Dim Visit2 as String
Visit1 = me.txtVisitDescription
Visit2 = Replace(Visit1, "'", "''") Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/9232-a-debug-challenge.html
DoCmd.RunSQL ("update tblsitevisits set visitdesc = '" & Visit2 & "' where
servicecall = txtservicecall and sitevisitnumber = txtlastsitevisit;")
The result is that the Update does not take.
I have stepped through, with warnings...run debug...and substituted values.
No warnings; empty debug window; and any configuration of substituted values
works.
I have even found that, after the first time stepping through, with
substituted values in a series of 6 SQL statements, each SQL statement works,
and the offending SQL will begin to work. Run without stepping through the Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
statements, or remove the substituted value statements, and the original SQL
again doesn't populate the field.
Anyone want to take a shot at this?
Thanks.
Sharkbyte Got anything to share on This Topic? Why not share your immediate thoughts/reaction with us! Login Now! or Sign Up Today! to share your views... Gurfateh! | 
28-Jul-2006, 08:00 AM
|  | Guest | | | | | | | | | | Re: A Debug Challenge... The problem is that the variables txtservicecall and txtlastsitevisit are
inside the quotes, so Access sees the text, not the value contained in the
variables.
DoCmd.RunSQL "update tblsitevisits set visitdesc = '" & Visit2 & _
"' where servicecall = " & txtservicecall & " and " & _
"sitevisitnumber = " & txtlastsitevisit
That assumes that servicecall and sitevistnumber are both numeric fields. If
they're text, you'll need quotes:
DoCmd.RunSQL "update tblsitevisits set visitdesc = '" & Visit2 & _
"' where servicecall = " & Chr$(34) & txtservicecall & Chr$(34) & _
" and sitevisitnumber = " & Chr$(34) & txtlastsitevisit & Chr$(34)
--
Doug Steele, Microsoft Access MVP http://I.Am/DougSteele
(no e-mails, please!)
"Sharkbyte" wrote in message
news:F8A4D6EB-0264-4F07-9318-6037EF84E0D4@microsoft.com... Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
> Okay. This one has got me. Maybe someone, here, can offer another
> suggestion...
>
> Here's the code:
>
> Dim Visit1 as String
> Dim Visit2 as String
>
> Visit1 = me.txtVisitDescription
> Visit2 = Replace(Visit1, "'", "''")
>
> DoCmd.RunSQL ("update tblsitevisits set visitdesc = '" & Visit2 & "' where
> servicecall = txtservicecall and sitevisitnumber = txtlastsitevisit;")
>
>
> The result is that the Update does not take.
>
> I have stepped through, with warnings...run debug...and substituted
values.
> No warnings; empty debug window; and any configuration of substituted
values Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
> works.
>
> I have even found that, after the first time stepping through, with
> substituted values in a series of 6 SQL statements, each SQL statement
works,
> and the offending SQL will begin to work. Run without stepping through
the
> statements, or remove the substituted value statements, and the original
SQL
> again doesn't populate the field.
>
> Anyone want to take a shot at this?
>
> Thanks.
>
> Sharkbyte | 
28-Jul-2006, 08:00 AM
|  | Guest | | | | | | | | | | Re: A Debug Challenge... Sharkbyte wrote:
>DoCmd.RunSQL ("update tblsitevisits set visitdesc = '" & Visit2 & "' where
>servicecall = txtservicecall and sitevisitnumber = txtlastsitevisit;")
>The result is that the Update does not take.
>
>I have stepped through, with warnings...run debug...and substituted values.
>No warnings; empty debug window; and any configuration of substituted values
>works.
I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
command instead of docmd.runsql. For ADO use
CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
adCmdText
If you're going to use docmd.setwarnings make very sure you put the
True statement in any error handling code as well. Otherwise weird
things may happen later on especially while you are working on the
app. For example you will no longer get the "Do you wish to save your
changes" message if you close an object. This may mean that unwanted
changes, deletions or additions will be saved to your MDB.
Also performance can be significantly different between the two
methods. One posting stated currentdb.execute took two seconds while
docmd.runsql took eight seconds. As always YMMV. Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232 Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm | 
28-Jul-2006, 08:00 AM
|  | Guest | | | | | | | | | | Re: A Debug Challenge... Doug:
Actually, txtServiceCall and txtLastSiteVisit reference TextBox controls, on
the form. In this case, txtServiceCall is blank or "variant" and
txtLastSiteVisit is GeneralNumber.
Thank you for your suggestions.
Sharkbyte
"Douglas J Steele" wrote:
> The problem is that the variables txtservicecall and txtlastsitevisit are
> inside the quotes, so Access sees the text, not the value contained in the
> variables.
>
> DoCmd.RunSQL "update tblsitevisits set visitdesc = '" & Visit2 & _
> "' where servicecall = " & txtservicecall & " and " & _
> "sitevisitnumber = " & txtlastsitevisit
>
> That assumes that servicecall and sitevistnumber are both numeric fields. If
> they're text, you'll need quotes:
>
> DoCmd.RunSQL "update tblsitevisits set visitdesc = '" & Visit2 & _
> "' where servicecall = " & Chr$(34) & txtservicecall & Chr$(34) & _
> " and sitevisitnumber = " & Chr$(34) & txtlastsitevisit & Chr$(34)
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
> "Sharkbyte" wrote in message
> news:F8A4D6EB-0264-4F07-9318-6037EF84E0D4@microsoft.com...
> > Okay. This one has got me. Maybe someone, here, can offer another
> > suggestion...
> >
> > Here's the code: Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
> >
> > Dim Visit1 as String
> > Dim Visit2 as String
> >
> > Visit1 = me.txtVisitDescription
> > Visit2 = Replace(Visit1, "'", "''")
> >
> > DoCmd.RunSQL ("update tblsitevisits set visitdesc = '" & Visit2 & "' where
> > servicecall = txtservicecall and sitevisitnumber = txtlastsitevisit;")
> >
> >
> > The result is that the Update does not take.
> >
> > I have stepped through, with warnings...run debug...and substituted
> values.
> > No warnings; empty debug window; and any configuration of substituted Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
> values
> > works.
> >
> > I have even found that, after the first time stepping through, with
> > substituted values in a series of 6 SQL statements, each SQL statement
> works,
> > and the offending SQL will begin to work. Run without stepping through
> the
> > statements, or remove the substituted value statements, and the original
> SQL
> > again doesn't populate the field.
> >
> > Anyone want to take a shot at this?
> >
> > Thanks.
> >
> > Sharkbyte
>
>
> | 
28-Jul-2006, 08:00 AM
|  | Guest | | | | | | | | | | Re: A Debug Challenge... Okay. Stupid question time...
I simply open the code window, and write. I have never paid much attention
to DAO or ADO. (Not that I don't intend on expanding my Access knowledge, at
a later time.)
How can I tell which I am working with? Is it ADO, by default? Access2003,
is what I use.
Thanks.
Sharkbyte
"Tony Toews" wrote:
> Sharkbyte wrote:
>
> >DoCmd.RunSQL ("update tblsitevisits set visitdesc = '" & Visit2 & "' where
> >servicecall = txtservicecall and sitevisitnumber = txtlastsitevisit;")
> >The result is that the Update does not take.
> >
> >I have stepped through, with warnings...run debug...and substituted values.
> >No warnings; empty debug window; and any configuration of substituted values
> >works.
>
> I prefer, if DAO, to use Currentdb.Execute strSQL,dbfailonerror
> command instead of docmd.runsql. For ADO use
> CurrentProject.Connection.Execute strCommand, lngRecordsAffected,
> adCmdText
>
> If you're going to use docmd.setwarnings make very sure you put the
> True statement in any error handling code as well. Otherwise weird
> things may happen later on especially while you are working on the
> app. For example you will no longer get the "Do you wish to save your Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
> changes" message if you close an object. This may mean that unwanted
> changes, deletions or additions will be saved to your MDB.
>
> Also performance can be significantly different between the two
> methods. One posting stated currentdb.execute took two seconds while Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=9232
> docmd.runsql took eight seconds. As always YMMV.
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Please respond only in the newsgroups so that others can
> read the entire thread of messages.
> Microsoft Access Links, Hints, Tips & Accounting Systems at
> http://www.granite.ab.ca/accsmstr.htm
> | 
Support Us! Become a Promoter! | | Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh! | (View-All)
Members who have read this thread : 0
| | There are no names to display. | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | | | Tools | Search | | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is On | | | | » Active Discussions | | | | | | | | | | | | | | | Amrit Today 09:17 AM 5 Replies, 361 Views | | | | | | | | | | | | | | | » Books You Should Read... | | | |