Workbook Closes after Submit button pressed

gmazza76

Well-known Member
Joined
Mar 19, 2011
Messages
767
Office Version
  1. 365
Platform
  1. Windows
Good Morning,

I am using the following code to submit a form that is completed by an agent in work. The file keeps closing when it has submitted and i need it to re loop after the Msg box at the end. If it it finds no open enquiries i need it then to confirm no work outstanding. Then to the file needs to stay open on the "Front Sheet" Tab

Any help would be appreciated:confused:


Private Sub cmdsubmit_Click()
Dim iRow As Long
Dim ws As Worksheet
If Me.JEN.Value = "" Then
MsgBox "Please Complete is this a justified Enquiry"
Else
If Me.AComm.Value = "" Then
MsgBox "Please Leave Your Comments"
Else
If Me.CBoxAdd.Value = "" Then
MsgBox "Please Enter Your Name"
Else
If Me.TextBox12.Value = "" Then
MsgBox "Please Enter Todays Date"
Else
Workbooks.Open Filename:="\\W2K6082\COMMON\SHARED\Simone's Team\Misc Spreadsheets\SimoneData.xls" 'File saved area
Set ws = Worksheets("Data")
iRow = ws.Cells(Rows.Count, 11) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the database
ws.Cells(iRow, 11).Value = Me.JEN.Value
ws.Cells(iRow, 12).Value = Me.AComm.Value
ws.Cells(iRow, 13).Value = Me.CBoxAdd.Value
ws.Cells(iRow, 14).Value = Me.TextBox12.Value
'clear the data
Me.JEN.Value = ""
Me.AComm.Value = ""
Me.CBoxAdd.Value = ""
Me.TextBox12.Value = ""
Me.txtdate.Enabled = True
Me.txtdate.SetFocus
Windows("SimoneData.xls").Activate
ActiveWindow.Close (True)
Application.Calculation = xlCalculationAutomatic

Application.ScreenUpdating = True

MsgBox "Your Car Park has been Completed"
ActiveWorkbook.Close False

End If
End If
End If
End If

End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
When i remove the info as suggested it just leaves the form showing with the previous data.:(
 
Upvote 0

Forum statistics

Threads
1,214,780
Messages
6,121,527
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top