Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

how do i use ' or " in a default value of a field

Discussion in 'Information Technology' started by alanstein001, Jul 28, 2006.

  1. alanstein001

    alanstein001
    Expand Collapse
    Guest

    how do i use ' or " in a default value of a field
     
  2. Loading...


  3. Ofer Cohen

    Ofer Cohen
    Expand Collapse
    Guest

    You can use the Open event of the form to set the default value of a field

    If Condition Then
    Me.[TextBoxName].DefaultValue = Value
    Else
    Me.[TextBoxName].DefaultValue = Value2
    End If

    Assuming that what you are looking for

    --
    Good Luck
    BS"D


    "alanstein001" wrote:

    > how do i use ' or " in a default value of a field
     
  4. alanstein001

    alanstein001
    Expand Collapse
    Guest

    Thanks - I only thought of putting the default in the table. Using a
    date-entry form works, though.

    "Ofer Cohen" wrote:

    > You can use the Open event of the form to set the default value of a field
    >
    > If Condition Then
    > Me.[TextBoxName].DefaultValue = Value
    > Else
    > Me.[TextBoxName].DefaultValue = Value2
    > End If
    >
    > Assuming that what you are looking for
    >
    > --
    > Good Luck
    > BS"D
    >
    >
    > "alanstein001" wrote:
    >
    > > how do i use ' or " in a default value of a field
     
  5. Jamie Collins

    Jamie Collins
    Expand Collapse
    Guest

    Ofer Cohen wrote:
    > > how do i use ' or " in a default value of a field

    >
    > You can use the Open event of the form to set the default value of a field


    FWIW I think the answer to the OP's question is to escape the quotes by
    doubling. For example, to use Ofer Cohen's sig as the column default:

    Sub DefaultWithQuotes()
    Dim cat
    Set cat = CreateObject("ADOX.Catalog")
    With cat
    .Create _
    "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=C:\DropMe.mdb"
    With .ActiveConnection
    .Execute _
    "CREATE TABLE Test1 (key_col INTEGER NOT" & _
    " NULL PRIMARY KEY, data_col VARCHAR(10)" & _
    " DEFAULT 'BS''''D' NOT NULL);"

    .Execute _
    "INSERT INTO Test1 (key_col) VALUES (1);"

    Dim rs
    Set rs = .Execute( _
    "SELECT key_col, data_col FROM Test1;")

    MsgBox rs.GetString
    rs.Close
    End With
    Set .ActiveConnection = Nothing
    End With
    End Sub

    Jamie.

    --
     

Share This Page