set default value in text box from vba level

wilow

Registered User.
Local time
Today, 14:36
Joined
Oct 23, 2012
Messages
14
Hi,

I have a problem of setting default values for text box.
I want that in my database date older than "X" days were canceled.
I would like to be able to set this value from the form

Here is the algorithm:
- I open the form - "Formularz1"
- I set the number of days (change value in text box and click "Change")
- I close the form
- When I open the form again, data older than the value (number of days) will be deleted from the database

In a file, which I enclose everything works like I wanted, but the number of days is stored in the table, but I would like to be inserted and changed the properties of the textbox. Is it be possible?
 

Attachments

A comment: It is vary rare that anything is deleted in a db. You can always find use for old data. Commonly, a record no longer required is set to Inactive, simply by having a boolean variable, by default active (true) when record was created and the deactivated (=false) on purpose at some stage. In your case, a typing mistake will be unrecoverable.
 
...will be unrecoverable.
I know. This database is very simple and I want to limit the amount of stored data. Data older than "X" will not ever need me.
 
Try the below code.

Code:
  Dim XDays As Integer, FormName As String
  XDays = Me.test_textbox
  FormName = Me.Name
    
  DoCmd.OpenForm FormName, acDesign, , , , acHidden
  Forms(FormName)!test_textbox.DefaultValue = XDays
  DoCmd.Close acForm, FormName, acSaveYes
 
This is perfect solution :D
Thank you very much :)
 
You're welcome, luck with your project.
 

Users who are viewing this thread

Back
Top Bottom