S
Simon Harris
Hi All,
I have a button on a form, when the button is clicked, this code is called
to open another form:
Private Sub TimeLogButton_Click()
If Len([Forms]![FRM_Switchboard]![SUBFRM_view_employees]) > 0 Then
stDocName = "FRM_order_time_log"
DoCmd.OpenForm stDocName, datamode:=acFormAdd
Else
MsgBox ("Please select employee first")
End If
End Sub
The form has various fields, which the user fills in, then clicks a further
button, which runs this code:
Private Sub NewTimeLogEntry_Click()
If Me.JobsCombo.Value = 0 Or Me.EmployeeCombo.Value = 0 Or
IsNull(Me.hours_spent.Value) Then
MsgBox ("Please select job, employee and enter number of hours
before clicking add")
Else
JobsComboCurrentValue = Me!JobsCombo.Value
EmployeeComboCurrentValue = Me!EmployeeCombo.Value
IDateCurrentValue = Me!Idate.Value
'Save the new time log entry and update the time log list
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
Forms![FRM_order_time_log]![TimeLog].Requery
DoCmd.GoToRecord , , acNewRec
Me!JobsCombo.Value = JobsComboCurrentValue
Me!EmployeeCombo.Value = EmployeeComboCurrentValue
Me!Idate.Value = IDateCurrentValue
End If
End Sub
Basically, the code saves the current record, and requeries the listbox on
the form, which displays a summary of records stored.
Problem is this: When I open the form, it seems to add a new record
immediatley - Before I have even clicked my save button.
Thanks lots,
Simon.
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!
I have a button on a form, when the button is clicked, this code is called
to open another form:
Private Sub TimeLogButton_Click()
If Len([Forms]![FRM_Switchboard]![SUBFRM_view_employees]) > 0 Then
stDocName = "FRM_order_time_log"
DoCmd.OpenForm stDocName, datamode:=acFormAdd
Else
MsgBox ("Please select employee first")
End If
End Sub
The form has various fields, which the user fills in, then clicks a further
button, which runs this code:
Private Sub NewTimeLogEntry_Click()
If Me.JobsCombo.Value = 0 Or Me.EmployeeCombo.Value = 0 Or
IsNull(Me.hours_spent.Value) Then
MsgBox ("Please select job, employee and enter number of hours
before clicking add")
Else
JobsComboCurrentValue = Me!JobsCombo.Value
EmployeeComboCurrentValue = Me!EmployeeCombo.Value
IDateCurrentValue = Me!Idate.Value
'Save the new time log entry and update the time log list
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, ,
acMenuVer70
Forms![FRM_order_time_log]![TimeLog].Requery
DoCmd.GoToRecord , , acNewRec
Me!JobsCombo.Value = JobsComboCurrentValue
Me!EmployeeCombo.Value = EmployeeComboCurrentValue
Me!Idate.Value = IDateCurrentValue
End If
End Sub
Basically, the code saves the current record, and requeries the listbox on
the form, which displays a summary of records stored.
Problem is this: When I open the form, it seems to add a new record
immediatley - Before I have even clicked my save button.
Thanks lots,
Simon.
--
-
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!