So, about 3 weeks ago, I decided to rebuild a database that my workplace uses. The original was built in '05 and has been stagnant since that time. I hadn't used Access since about 2002 and had never written code before. Needless to say, this was a big undertaking. Everything I've learned is all self taught over the last few weeks. Poke at it and see what happens type of approach.
Very frequently, I decide what I want to do and then turn to the interwebs to figure out how. 9 times out of 10, this forum is where I found intelligible answers. Which leads me to the first question I'm going to ask on my own instead of fishing for an existing answer for hours.
So without further adieu, I have this code snippet that isn't working as intended:
This is on a form that (I hope obviously) is intended to close out an email (aka:trouble ticket). When tabbing through fields, when I land in txtDate the =NOW() is working as intended. However, in an attempt to ensure nothing was ever submitted w/o a date/time entered, I created the If statement to put =NOW() into the txtDate field if it was empty upon clicking cmdSubmit. But it doesn't work. I don't get any errors, but nothing happens. Why not?
What I've included is the entire code for that form. I am not using any macros either (forcing myself to learn the equivalent vba). The txtDate control is not populating with any Default data, so by all accounts it should be Null unless it gets focus.
Advice is kindly appreciated. Thanks!
Very frequently, I decide what I want to do and then turn to the interwebs to figure out how. 9 times out of 10, this forum is where I found intelligible answers. Which leads me to the first question I'm going to ask on my own instead of fishing for an existing answer for hours.
So without further adieu, I have this code snippet that isn't working as intended:
Code:
Private Sub txtDate_GotFocus()
Me.txtDate = Now()
End Sub
Private Sub cmdCancel_Click()
If Me.Dirty Then
Me.Undo
End If
DoCmd.Close acForm, "frmCloseEmail"
End Sub
Private Sub cmdSubmit_Click()
If Me.txtDate = Null Then
Me.txtDate = Now()
End If
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close acForm, "frmCloseEmail"
Forms!frmGUI!listActiveEmails.Requery
End Sub
This is on a form that (I hope obviously) is intended to close out an email (aka:trouble ticket). When tabbing through fields, when I land in txtDate the =NOW() is working as intended. However, in an attempt to ensure nothing was ever submitted w/o a date/time entered, I created the If statement to put =NOW() into the txtDate field if it was empty upon clicking cmdSubmit. But it doesn't work. I don't get any errors, but nothing happens. Why not?
What I've included is the entire code for that form. I am not using any macros either (forcing myself to learn the equivalent vba). The txtDate control is not populating with any Default data, so by all accounts it should be Null unless it gets focus.
Advice is kindly appreciated. Thanks!
Last edited: