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 » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

comma confussion!



 
 
Thread Tools Display Modes
  #1  
Old February 23rd, 2006, 01:30 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default comma confussion!

Hello all,
I have a bit of code that i execute to check for a record, then alow or
disalow the record to be edited.
it grabs the value from an unboud text box, here in lies the problem,
if there is a comma in the name that is entered, its a nongo, error
3705. i get so confused when alowing for special characters in vb, can
any one recomend a change?


thanks in advance!:
Stu

*****************************CODE***************** ***************

Private Sub cmdAddClient_Click()

Dim varFindDup As Variant
Dim varFindRep As Variant
Dim intReplaceRep As Integer


varFindDup = DLookup("[Client]", "tblClientList", "[Client] = '"
& Me![txtAddClient] & "'")

varFindRep = DLookup("[AccountManager]", "qryFindRep", "[Client]
= '" & Me![txtAddClient] & "'")


If IsNull(varFindDup) Then

DoCmd.RunSQL "INSERT INTO tblClientList
(AccountManagerID, Client) VALUES ('" & Me.txtID & "', '" &
Me.txtAddClient & "')"
' DoCmd.Requery

Else
intReplaceRep = MsgBox("This Client Belongs to " &
varFindRep & " are you SURE you want to change it?", vbYesNo)

If intReplaceRep = vbYes Then

DoCmd.RunSQL "UPDATE tblClientList SET
[AccountManagerID] = '" & Me.txtID & "' WHERE [Client] = '" &
Me.txtAddClient & "'"

Else
MsgBox "Action Canceled"
End If

End If
End Sub
****************************END CODE***********************************

  #2  
Old February 23rd, 2006, 04:08 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default comma confussion!

When you say comma are you really referring to an apostrophe (')? Instead of
using the single quote or apostrophe character as the string delimeter
within your SQL try using a pair of double quote characters. For example:

varFindDup = DLookup("[Client]", "tblClientList", "[Client] = """ &
Me![txtAddClient] & """")

Access will replace each pair of quote characters with a single quote
character that will be used as the string delimiters for the comparison
value. Since the apostrophe is no longer in use a string delimiter it can be
used as part of the comparison string itself.

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

Stu Dongel wrote:
Hello all,
I have a bit of code that i execute to check for a record, then alow or
disalow the record to be edited.
it grabs the value from an unboud text box, here in lies the problem,
if there is a comma in the name that is entered, its a nongo, error
3705. i get so confused when alowing for special characters in vb, can
any one recomend a change?


thanks in advance!:
Stu

*****************************CODE***************** ***************

Private Sub cmdAddClient_Click()

Dim varFindDup As Variant
Dim varFindRep As Variant
Dim intReplaceRep As Integer


varFindDup = DLookup("[Client]", "tblClientList", "[Client] = '"
& Me![txtAddClient] & "'")

varFindRep = DLookup("[AccountManager]", "qryFindRep", "[Client]
= '" & Me![txtAddClient] & "'")


If IsNull(varFindDup) Then

DoCmd.RunSQL "INSERT INTO tblClientList
(AccountManagerID, Client) VALUES ('" & Me.txtID & "', '" &
Me.txtAddClient & "')"
' DoCmd.Requery

Else
intReplaceRep = MsgBox("This Client Belongs to " &
varFindRep & " are you SURE you want to change it?", vbYesNo)

If intReplaceRep = vbYes Then

DoCmd.RunSQL "UPDATE tblClientList SET
[AccountManagerID] = '" & Me.txtID & "' WHERE [Client] = '" &
Me.txtAddClient & "'"

Else
MsgBox "Action Canceled"
End If

End If
End Sub
****************************END CODE***********************************


  #3  
Old February 23rd, 2006, 06:50 AM posted to microsoft.public.access.forms
external usenet poster
 
Posts: n/a
Default comma confussion!

I did mean apostrophie! thank you so much, worked like a charm!

 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Applying Indian comma style NAVEEN General Discussion 1 February 22nd, 2006 08:59 AM
In Word, how can I automatically insert a comma between numbers? sharris General Discussion 4 February 4th, 2006 04:32 AM
Importing a part of a big comma delimited csv-file smari Worksheet Functions 0 October 6th, 2005 02:32 PM
Convert Excel to comma delimited text deacs General Discussion 2 October 6th, 2004 11:02 PM
separate for point and comma Frank Dulk Using Forms 0 August 3rd, 2004 02:55 AM


All times are GMT +1. The time now is 03:38 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.