Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Placing default values via code issues

Status
Not open for further replies.

EddyLLC

Technical User
Mar 15, 2005
304
US
I use the following code to take user input and load it into a backend table as default value for a specific field. The issue is some name entered by users have commas in them and unless those name are surrounded by quotes I receive an error when I attempt to put them in as default values. Because I put the name into a variable I am at a loss as to how to surround the name with quotes so it can be placed into the default value field. Thanks for any help.

Eddy

Set dbLocal = CurrentDb()
DatabasePath = ap_GetDatabaseProp(dbLocal, "LastBackEndPath")
DatabaseName = "DATA.MDB"
DatabasePath = DatabasePath & DatabaseName
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsUpdate = wrkDefault.OpenDatabase(DatabasePath, True)

If Not IsNull(Me!Name) Then
Dim strUserName As String
strDeclarant = Me!Name
Set tdfUpdate = dbsUpdate.TableDefs("flkpNames")
With tdfUpdate
Set tdfField = .Fields("Name")
tdfField.Properties("DefaultValue").Value = strUserName
End With


End If
 
Perhaps this ?
tdfField.Properties("DefaultValue").Value = Chr(34) & strUserName & Chr(34)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top