Easiest way to input Date & Time into Date/Time field

nevermind... I'm still way off here, just trying to get the value of the checkbox read is a pain for this newb, let alone inserting a particular value into a field based on the checkbox.
 
Last edited:
Ok, the following works:

Code:
Private Sub Submit_Click()
Dim strSQL1 As String
Dim strSQl2 As String
Dim strSQL3 As String
DoCmd.SetWarnings (WarningsOff)
    strSQL1 = "INSERT INTO Requests (Emp_no, ReqDate, ReqTime) values (Forms!Entry!Empno, Forms!Entry!Calendar0, '14:00');"
    strSQl2 = "INSERT INTO Requests (Emp_no, ReqDate, ReqTime) values (Forms!Entry!Empno, Forms!Entry!Calendar0, '18:00');"
    strSQL3 = "INSERT INTO Requests (Emp_no, ReqDate, ReqTime) values (Forms!Entry!Empno, Forms!Entry!Calendar0, '20:00');"
 
        If Me.Check1.Value = -1 Then DoCmd.RunSQL strSQL1
        If Me.Check2.Value = -1 Then DoCmd.RunSQL strSQl2
        If Me.Check3.Value = -1 Then DoCmd.RunSQL strSQL3
 
DoCmd.SetWarnings (warningsOn)
End Sub

Not that it's a big deal, but Me.Empno or Me!Empno doesn't work....
 
What datatypes are Emp_No, ReqDate and ReqTime?

Is this for a subform or a form?
 
Number, Date, Date. Fields are on the main form. It's already typed, I just was wondering why Me didn't work from the main form like this.
 
You probably need this:

Code:
    strSQL1 = "INSERT INTO Requests (Emp_no, ReqDate, ReqTime) values ([B][COLOR=red]" & [/COLOR][/B]Forms!Entry!Empno [B][COLOR=red]& "[/COLOR][/B],[COLOR=red][B]#" &[/B][/COLOR] Forms!Entry!Calendar0 [B][COLOR=red]& "#[/COLOR][/B], '14:00');"
    strSQl2 = "INSERT INTO Requests (Emp_no, ReqDate, ReqTime) values ([B][COLOR=#ff0000]" & [/COLOR][/B]Forms!Entry!Empno [B][COLOR=red]& "[/COLOR][/B],[COLOR=red][B]#" &[/B][/COLOR] Forms!Entry!Calendar0 [B][COLOR=red]& "#[/COLOR][/B], '18:00');"
    strSQL3 = "INSERT INTO Requests (Emp_no, ReqDate, ReqTime) values ([B][COLOR=#ff0000]" & [/COLOR][/B]Forms!Entry!Empno [B][COLOR=red]& "[/COLOR][/B],[COLOR=red][B]#" &[/B][/COLOR] Forms!Entry!Calendar0 [B][COLOR=red]& "#[/COLOR][/B], '20:00');"
 

Users who are viewing this thread

Back
Top Bottom