Table Default Values

T

The Brat

Is it possible to set the default value of a field in the table to either a
value entered into a message box or a value entered into another table?

I'm importing data from a text file into an existing table. I have been
manually changing the default value for the report date field each time I
import a new report, but since I won't be doing the importing anymore, would
like to automate or simplify this process.

Any suggestions?
 
C

Clifford Bass

Hi,

If you want the current date you can just use =Date(). If some other
date, you can do something like this:

Public Function LoadSummaries() As Boolean

Dim strInput As String

LoadSummaries = False

strInput = InputBox("Enter summary as-of date:")
If IsDate(strInput) Then

CurrentDb.TableDefs("tblRequisition_Summary_Data").Fields("Summary_Date" _
).DefaultValue = "#" & strInput & "#"
DoCmd.OpenQuery "qryUse for Adding Data", acViewNormal, acAdd
LoadSummaries = True
Else
If strInput <> "" Then
MsgBox """" & strInput & """ is not a valid date.",
vbExclamation + _
vbOKOnly
End If
End If

End Function

In this case the query showed the table without the summary date and in
add mode. The user then copied the data from a web site and paste-appended
the new data into the table.

Hope that helps,

Clifford Bass
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top