Currently I have a 3 second loop in place and sometimes that works and sometimes it does not. Here is the problem. The main form is unbound. The reason for this is that I do not want anything writen to the table with out being checked out first. No data is written until the use clicks the 'Save Record' button. The subform is bound to a query that limits the data to 'that' user only. The subform reflects the entries being made by the input on the main form. I have a requery the works 50% of the time. If the user clicks the 'Save Record' it shows up automaticly for them. I want 'EVERY' entry to show up with out them having to hit F5 or something else to get the newest data to show in the subform.
Here is the code.
Here is the code.
Code:
Private Sub btnSaveRecord_Click() 'Make sure date is filled out If Nz(txtActivityDate, "") = "" Then MsgBox "The Date Field is Required" txtActivityDate.SetFocus Exit Sub End If ' open connection and recordset Dim cnConnection As ADODB.Connection Set cnConnection = New ADODB.Connection Dim strConnection As String strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & CurrentProject.Path & "\metrix_front.mdb;" cnConnection.Open strConnection Dim rsRecordset As ADODB.Recordset Set rsRecordset = New ADODB.Recordset rsRecordset.CursorType = adOpenDynamic rsRecordset.LockType = adLockPessimistic rsRecordset.Open "SELECT * FROM tblDailyPlan", cnConnection 'write the new record data to table DoCmd.Hourglass True rsRecordset.AddNew rsRecordset!ActivityDate = txtActivityDate rsRecordset!ShipClass_ID = txtShipClass rsRecordset!Activities_ID = txtActivity If IsNull(Me.txtInputs) Then rsRecordset!Inputs = 0 Else rsRecordset!Inputs = txtInputs End If If IsNull(Me.txtCompletedActions) Then rsRecordset!CompletedAct = 0 Else rsRecordset!CompletedAct = txtCompletedActions End If rsRecordset!ActualTime = txtActualTime rsRecordset!Comments = txtComments rsRecordset!Employee_ID = [Forms]![frmLogonAssist]![Employee_ID] rsRecordset.Update 'clear form and close connections Dim ctl As Control On Error Resume Next For Each ctl In Me.Controls ctl.Value = Null Next ctl 'Cleanup rsRecordset.Close cnConnection.Close Set rsRecordset = Nothing Set cnConnection = Nothing txtInputs.Enabled = True 'reactivates control in case "Admin" or "Leave" was selected txtCompletedActions.Enabled = True 'reactivates control in case "Admin" or "Leave" was selected txtShipClass.Enabled = True 'reactivates control in case "Admin" or "Leave" was selected ' dont like this but it works - delay is so that recordset can be successfully writen to table before requery runs TWait = Time TWait = DateAdd("s", 2, TWait) Do Until TNow >= TWait TNow = Time Loop DoCmd.Hourglass False Forms![frmDailyPlan]![subfrmDailyPlanRange].Form.Requery Me.[txtActivityDate].SetFocus End Sub
Comment