I have a form that only consists of one Text Box which I have called txtCOBDate.
This is what my form looks like - it sets the date in the text box to previous date.
I managed to set the date in the form to previous date using this code:
Code:
Private Sub Form_Load()
Dim dt As Date
Select Case Weekday(Now())
Case 2:
dt = Date - 3
Case Else:
dt = Date - 1
End Select
Me.Controls("txtCOBDate") = dt
What I am trying to also do is to update a one and only field called COBDate in my table called tbl_COBDate
I am also trying to do this within the same code as above using this line of code:
Code:
CurrentDb.Execute "UPDATE tbl_COBDate SET COBDate = #" & Format(dt, "mm/dd/yyyy") & "#"
The code runs fine without any errors but its not updating the field in my table.
Would anyone know why?
I am trying to create a link between the the value in the text box in my form with the value in the field of my table - maybe there is another way to achieve this??