Call Form Text Box for Table Field Default Value

dapfeifer

Bringing Maverick Mojo
Local time
Today, 03:06
Joined
Jun 17, 2008
Messages
68
Hey everyone, I'm new here and looking for a little help.

I've got a table that has a date field, and I need that field's default value to be assigned to a user-entered date. I've tried the following:

- Having the date field's Default Value option call the text field on a form that the value is stored in (I'm fairly positive this won't work, but I thought I'd try it).

- Since the Default Value is needed during the import of an external file to a table, I've tried adding code that will call the date entry form, allow the user to select a date, and then try to push that date to the Default Value of the table's date field. Again, the date is being stored in a text box, so I'm trying to send it from there but having no such luck.

I realize that I may have stated things a little bit of a confusing way, so if I need to clarify please say so and I'll do my best!

Thanks ahead of time,
D. Pfeifer
 
You can try this:

Code:
  Dim db            As DAO.Database
  Dim tdf           As DAO.TableDef

  Set db = CurrentDb()
  Set tdf = db.TableDefs("TableName")

  tdf.Fields("FieldName").Properties("defaultvalue") = #06/15/2008#

  Set tdf = Nothing
  Set db = Nothing
 
Thanks pbaldy, slid this into my OK cmd button code and it worked like a charm, except in place of the hard-coded date (#06/15/2008#) I used the value of my text box (txtDate.Value). Thanks for the help, its much appreciated!
 
Glad it worked for you. Welcome to the site by the way.
 

Users who are viewing this thread

Back
Top Bottom