Results 1 to 10 of 10
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Set value of textbox On_Load (A2k3 SP2)

    Hi All,
    In trying to set the value of a textbox in the On_Load event of its' form and I'm finding that makes the form Dirty. Is there an event or method where I can do this and/or "fake-out" the form into thinking it isn't Dirty?
    Thank you.
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    The Dirty property is read/write, so you can use

    Me.Dirty = False

    after setting the value of the textbox.

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    Thanks Hans,
    I'm sorry, I failed to mention one other criteria. I don't want the data to be saved at this point yet. Me.Dirty = False saves the record.
    <img src=/S/sorry.gif border=0 alt=sorry width=15 height=15>
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    Why do you want to do this?

    I guess the text box is bound, thought about using an unbound control?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    I didn't know that setting Dirty to False saves the record (in Word and Excel, you can set the Saved property of a document/workbook to True without actually saving it), but that's indeed what happens.
    So, I don't think you can set the value of a bound control and tell Access that the record shouldn't be saved (unless you undo the value, but that's probably not what you want).

  6. #6
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    Hi Pat,
    Yes, it is a bound control and yeah, I have thought of unbound.
    I am making a "Report Building" database, which pulls data from 2 SQL Server dbs and an Oracle db, allows the user to filter and/or order it, saves the necessary variables/strings to recreate the pertinent data and, this is the important part, saves any added comments, the Report Name, the Report title, etc into the database for a historical record of generated reports. I was hoping to use code to generate editable default values for these user inputs.
    I am very open to suggestions/methods on how this might be accomplished.
    Thanks.
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    Why don't you set the Default Value property of the relevant field(s)?

  8. #8
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    Hi Hans
    Sorry for the delay. I've tried setting the Default Value in the OnLoad (OnOpen as well) and I get #Name? in the textbox when the form opens.
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    If it's for a text field, you must enclose the value in quotes, for example

    Me.txtReportTitle.DefaultValue = Chr(34) & "This is the default title" & Chr(34)

    Without the quotes Chr(34), you'll get the #Name error.

  10. #10
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Set value of textbox On_Load (A2k3 SP2)

    Hi Hans,
    Again, sorry for the delay. For the past 2+ weeks I've been doing projects at night while I've been attending classes (work related) during the day.

    I still received the #Name? error when I tried the following both in the OnLoad and the OnOpen events.
    ---original---
    strReportTitle = "Defect Data Quality Report for " & strReportDate
    Me!txtReportTimeOf.DefaultValue = strReportTitle
    ---First---
    strReportTitle = Chr(34) & "Defect Data Quality Report for " & Chr(34) & strReportDate
    Me!txtReportTimeOf.DefaultValue = strReportTitle
    ---Second---
    Me!txtReportTimeOf.DefaultValue = Chr(34) & "Defect Data Quality Report for " & Chr(34) & strReportDate
    ---Third---
    strReportTitle = "Defect Data Quality Report for "
    Me!txtReportTimeOf.DefaultValue = strReportTitle
    ---
    Then after the Third trial <img src=/S/doh.gif border=0 alt=doh width=15 height=15> <img src=/S/bingo.gif border=0 alt=bingo width=15 height=22> I wrote it the correct way......in the OnOpen event
    Me!txtReportTimeOf.DefaultValue = Chr(34) & "Defect Data Quality Report for " & strReportDate & Chr(34)
    ---
    Sometime I just insist on looking too far away....... <img src=/S/eyeout.gif border=0 alt=eyeout width=15 height=15>
    Thank you.
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •