Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting the Default Value for a table column using a parameter 1

Status
Not open for further replies.

bdpitta

MIS
Nov 7, 2002
49
I have a button on one of my forms that sets the defualt value for a column in one of my tables. Here is the code:

Private Sub Command3_Click()
Dim con As ADODB.Connection
Dim sql As String

Set con = CurrentProject.Connection
sql = "ALTER TABLE BadDebts
ALTER COLUMN DateReserved SET DEFAULT 1/1/2000"

With con
.Execute sql
.Close
End With
Set con = Nothing
End Sub

This code works just fine, but what I would like to do is to enable the user to enter a default date of their choosing. How can I alter this code (or write something completely different) that would allow for the user to enter a date to be used in the alter table statement? (perhaps with a textbox or inputbox..)?

Thankyou

 
Try this:
sql = "ALTER TABLE BadDebts
ALTER COLUMN DateReserved SET DEFAULT " & inputbox("Enter Default Date in m/d/yyyy format.")


Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top