Hi
I am trying to save a record in the form and once I click the save button. Data is saved to the table. and the form is not cleared for the next entry.
Please help me with this.
Hi
I am trying to save a record in the form and once I click the save button. Data is saved to the table. and the form is not cleared for the next entry.
Please help me with this.
records save automatically, but to move to the new rec, add:
DoCmd.GoToRecord , , acNewRec
I tried that. It is not working. My controls are unbound. I placed the above code in the after update event of the save button.
Or am I placing the code at the wrong place?
Here is the code:
Private Sub ADD_Click()
Dim rs As Recordset
On Error GoTo ErrHandler
If MsgBox("Do you want to add the record.", vbQuestion + vbYesNo, "Add New Record?") = vbYes Then
Set rs = CurrentDb.OpenRecordset("Copy Of Projects_T", dbOpenDynaset, dbAppendOnly)
rs.AddNew
rs.Fields("Element").Value = Me.Element.Value
rs.Fields("ProjectName").Value = Me.ProjectName.Value
rs.Fields("WBS").Value = Me.WBS.Value
rs.Fields("Status").Value = Me.Status.Value
rs.Fields("DateClosed").Value = Me.DateClosed.Value
rs.Fields("Category").Value = Me.Category.Value
rs.Fields("Closed").Value = Me.Closed.Value
rs.Update
MsgBox "Record saved.", vbInformation, "Record Saved"
End If
Exit Sub
DoCmd.GoToRecord , , acNewRec
ErrHandler:
MsgBox Err.Description, vbExclamation, "Error Occurred"
End Sub
The DoCmd.GoToRecord will never be executed, as you have an Exit Sub right before it.
In any case, that might cause an error anyway if the form is unbound (in which case remove the line).
If the form is unbound, you will need to blank out all the unbound fields to make them empty. You can add that code right before the Exit Sub.
I placed the DoCmd.GoToRecord , , acNewRec before the exit sub. Its not working.
The DoCmd.GoToRecord will never be executed, as you have an Exit Sub right before it.
In any case, that might cause an error anyway if the form is unbound (in which case remove the line).
If the form is unbound, you will need to blank out all the unbound fields to make them empty. You can add that code right before the Exit Sub.
Tell me more.Its not working.
As I mentioned in post #4, you have to blank out the fields...
Code:MsgBox "Record saved.", vbInformation, "Record Saved" LastName = Null FirstName = Null UserLogID = Null EmailAddress = Null Company = Null SubContractor = Null PositionTitle = Null OfficeLocation = Null MobileNumber = Null BusinessTelephone = Null ContractNumber = Null TaskOrder = Null UDF2 = Null UDF3 = Null End If 'DoCmd.GoToRecord , , acNewRec Exit Sub
Sorry I missed that.
Its working now!
Thank you tons!![
QUOTE=davegri;404710]As I mentioned in post #4, you have to blank out the fields...
[/QUOTE]Code:MsgBox "Record saved.", vbInformation, "Record Saved" LastName = Null FirstName = Null UserLogID = Null EmailAddress = Null Company = Null SubContractor = Null PositionTitle = Null OfficeLocation = Null MobileNumber = Null BusinessTelephone = Null ContractNumber = Null TaskOrder = Null UDF2 = Null UDF3 = Null End If 'DoCmd.GoToRecord , , acNewRec Exit Sub
BTW, if you want the 'Refresh Employee List' button to show everyone, change its code to this:
Code:Private Sub Command48_Click() sRowsource = "SELECT [Copy Of Employee_T].FullName, [Copy Of Employee_T].EmployeeID, [Copy Of Employee_T].deployed FROM [Copy Of Employee_T] " lstEmployee.RowSource = sRowsource txtSearch = Null lstEmployee.Requery End Sub
Thank you so much!!
I was trying to figure that out.
Thanks again!!
BTW, if you want the 'Refresh Employee List' button to show everyone, change its code to this:
Code:Private Sub Command48_Click() sRowsource = "SELECT [Copy Of Employee_T].FullName, [Copy Of Employee_T].EmployeeID, [Copy Of Employee_T].deployed FROM [Copy Of Employee_T] " lstEmployee.RowSource = sRowsource txtSearch = Null lstEmployee.Requery End Sub