Insert Text

  • Thread starter Thread starter DS
  • Start date Start date
D

DS

I'm inserting a mesage into a text field. However when there is a comma in
it, it gives me an error message. Can this be fixed?

Set db = CurrentDb
With db.TableDefs("tblChecksTMP")
..Fields("ChkMessage").DefaultValue = IIf(IsNull(Me.TxtMessage), "",
Me.TxtMessage)
End With

Me.TxtMessage is an unbound textbox
ChkMessage is a Textfield

Thanks
DS
 
I read this and your previous post. What is your objective? If you can tell
us what it is you want to do, perhaps we can help with the how to do it.
 
DS said:
I'm inserting a mesage into a text field. However when there is a comma in
it, it gives me an error message. Can this be fixed?

Set db = CurrentDb
With db.TableDefs("tblChecksTMP")
.Fields("ChkMessage").DefaultValue = IIf(IsNull(Me.TxtMessage), "",
Me.TxtMessage)
End With

Me.TxtMessage is an unbound textbox
ChkMessage is a Textfield


The DefaultValue property is a string that will be
**evaluated** when it is used.

For example, if you use:
x.DefaultValue = "1+2"
Then text box will have 3 assigned when you create a new
record. If you really want the assigned value to be the
string "1+2", then you need to use:
x.DefaultValue = """1+2"""

With all that in mind, your code ahould be:

.....DefaultValue = IIf(IsNull(Me.TxtMessage), "", _
"""" & Me.TxtMessage & """")
 
Merely trying to input a message of 50 characters or less in to a text
field.
Marshall Just answered it.
Thanks
DS
 
Back
Top