Save Form.

Evagrius

Registered User.
Local time
Today, 01:16
Joined
Jul 10, 2010
Messages
170
Hi Everyone,

I have a small issue. I have a pop up from with some command buttons and one textbox. One of the command buttons imports data from Excel into Access - that works fine. I wanted to place a date in the textbox everytime data is imported into the db.

The text box is unbound, and I the date successfully appears in the txtbox, but it does not save. I tried a label but had the same issue.

Also, do I have to have a form open in order to place a value in a control of that form? Thank you for any help!

Code:
Sub bl()
DoCmd.OpenForm "frmOP", acNormal
Forms!frmOP!txtMyUpdateDate.Value = Date
DoCmd.Close acForm, "frmOP", acSaveYes
End Sub
 
Where would you like to save the date? You're saving it in a table right? You can't save it in the form.
 
So there is no way to just save it in the Textbox? I will have to create table just for that one value?

If I set the controlsource of the txtbox to = "=date()" . . .why wouldn't that save??
 
Last edited:
I will have to create table just for that one value?

You have a few options:
- you can save to a text file
- you can save to a seperate table
- you can save a DateTime stamp in the records that you're importing

For example:

EmployeeID (AutoNumeric), FirstName (Text), LastName (Text), Inserted (DateTime)
 
Okay - thanks - I updated my previous thread. Forgive me for being dense, but, so that I can be clear, it is not possible to set the controlsource of a textbox to a date and save that?
 
It is not possible to set the controlsource of a textbox to a date and save that?

You would be saving a form property. Normally properties are not really intented to store values. :-) However, you could do it your way something like this:

Code:
Dim d As Date
d = Now()
Docmd.Openform "frmSomeForm", View:=acDesign
txtTest.DefaultValue = d
DoCmd.Save acForm, "frmSomeform"
DoCmd.Close "frmSomeForm"
 
Thanks Hbrems - that seems to be working. I had to make a slight change here,


Code:
.DefaultValue = Chr(34) & d & Chr(34)

It didn't work without the Chr() - Thanks :)
 

Users who are viewing this thread

Back
Top Bottom