Welcome to SPN

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

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $95

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.

    --
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page