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 |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
comma confussion!
I did mean apostrophie! thank you so much, worked like a charm!
|
Thread Tools | |
Display Modes | |
|
|
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 |