I have this form where user enters a time (i.e - 15:45) into a textbox which is stored to this field in the database. For data checking purposes we also have two fields, one to store the hour (15) and the other field to store minute (45). My problem is my code for some reason cannot update the hour and minute field.
This is my code. Basically users enters to tm_rand text box 15:45. Just for simplicity I am just trying to update hour field (h_rand) but even this is not working. I ran the query to test SQL code and it works so SQL code should be alright. The msgbox test123 does appear and no error msg.
This is my code. Basically users enters to tm_rand text box 15:45. Just for simplicity I am just trying to update hour field (h_rand) but even this is not working. I ran the query to test SQL code and it works so SQL code should be alright. The msgbox test123 does appear and no error msg.
Code:
Private Sub tm_rand_AfterUpdate()
Dim db As Database
Dim var1 As String
Dim h As Integer
Dim m As Integer
h = Left(tm_rand, 2)
m = Mid(tm_rand, 4, 2)
Set db = CurrentDb()
var1 = "UPDATE Entry4 SET h_rand = " & h & " where [id] = '" & id & "'"
DoCmd.SetWarnings False
DoCmd.RunSQL var1
MsgBox ("test123")