douginiraq
Registered User.
- Local time
- Yesterday, 16:44
- Joined
- Nov 8, 2011
- Messages
- 14
I have a Unbound Form with 4 bound sub-forms. Each of the sub forms is identical in function. See the code below:
frmP4RT
--------------------------
Private Sub btnStart4_Click()
Me.btnStop4.Enabled = True
Dim IAB_WATER_TEST_DB As DAO.Database
Dim tblP4RT As DAO.Recordset
Set IAB_WATER_TEST_DB = CurrentDb
Set tblP4RT = IAB_WATER_TEST_DB.OpenRecordset("tblP4RT")
tblP4RT.AddNew
tblP4RT("STARTDATETIME").Value = Now()
tblP4RT.Update
Me.btnStop4.SetFocus
Me.lblW4PC.BackColor = vbGreen
Me.btnStart4.Enabled = False
End Sub
Private Sub btnStop4_Click()
Me.btnStart4.Enabled = True
Dim IAB_WATER_TEST_DB As DAO.Database
Dim tblP4RT As DAO.Recordset
Set IAB_WATER_TEST_DB = CurrentDb
Set tblP4RT = IAB_WATER_TEST_DB.OpenRecordset("tblP4RT", dbOpenDynaset)
tblP4RT.MoveLast
tblP4RT.Edit
tblP4RT("STOPDATETIME") = Now()
tblP4RT.Update
tblP4RT.Close
Me.btnStart4.SetFocus
Me.lblW4PC.BackColor = vbRed
Me.btnStop4.Enabled = False
End Sub
-----------------------------------
What this does is simply enter a start /stop date and time into the PUMP 4 RUN TIME table and then set the enabled state and label color to give the user the visual of the pump status and prevent the controls being operated consecutively resulting in double entries on the start time and a blank stop time.
The above is working perfectly.
The Problem:
When I close the unbound form and reopen I get the appearance that the pumps are all in the "off state". I need to retain the "current state" of the controls when closed and when the form is opened again have the controls set the same as when closed so the running pumps show as still running and be able to stop them and have the record in the table be correct.
I suspect I need to use the OnClose() command and make some Module to make the save state but my research has turned up nothing significant.
frmP4RT
--------------------------
Private Sub btnStart4_Click()
Me.btnStop4.Enabled = True
Dim IAB_WATER_TEST_DB As DAO.Database
Dim tblP4RT As DAO.Recordset
Set IAB_WATER_TEST_DB = CurrentDb
Set tblP4RT = IAB_WATER_TEST_DB.OpenRecordset("tblP4RT")
tblP4RT.AddNew
tblP4RT("STARTDATETIME").Value = Now()
tblP4RT.Update
Me.btnStop4.SetFocus
Me.lblW4PC.BackColor = vbGreen
Me.btnStart4.Enabled = False
End Sub
Private Sub btnStop4_Click()
Me.btnStart4.Enabled = True
Dim IAB_WATER_TEST_DB As DAO.Database
Dim tblP4RT As DAO.Recordset
Set IAB_WATER_TEST_DB = CurrentDb
Set tblP4RT = IAB_WATER_TEST_DB.OpenRecordset("tblP4RT", dbOpenDynaset)
tblP4RT.MoveLast
tblP4RT.Edit
tblP4RT("STOPDATETIME") = Now()
tblP4RT.Update
tblP4RT.Close
Me.btnStart4.SetFocus
Me.lblW4PC.BackColor = vbRed
Me.btnStop4.Enabled = False
End Sub
-----------------------------------
What this does is simply enter a start /stop date and time into the PUMP 4 RUN TIME table and then set the enabled state and label color to give the user the visual of the pump status and prevent the controls being operated consecutively resulting in double entries on the start time and a blank stop time.
The above is working perfectly.
The Problem:
When I close the unbound form and reopen I get the appearance that the pumps are all in the "off state". I need to retain the "current state" of the controls when closed and when the form is opened again have the controls set the same as when closed so the running pumps show as still running and be able to stop them and have the record in the table be correct.
I suspect I need to use the OnClose() command and make some Module to make the save state but my research has turned up nothing significant.