Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirmation msgbox

Status
Not open for further replies.

5556

Programmer
May 27, 2003
17
0
0
US
When the user clicks the submit button on my form i want a message to popup that says the record has been added. I am not sure how to do this with the code i currently have for the submit button. This is a sample of some of the code.

Private Sub CmdSubmit_Click()

Dim db As Database, sourceset As Recordset
Set db = DBEngine.Workspaces(0).Databases(0)
Set sourceset = db.OpenRecordset("report1")

On Error GoTo error_submit

sourceset.AddNew
sourceset!Employee_Name = Text137.Value
sourceset!Stop1 = Combo0.Value
sourceset!Origin = Combo8.Value
sourceset!Stop2 = Combo2.Value
sourceset!Stop3 = Combo4.Value
sourceset!Stop4 = Combo6.Value
sourceset!Stop1_dist = Text10.Value
sourceset!Stop2_dist = Text13.Value
sourceset!Stop3_dist = Text14.Value
sourceset!Stop4_dist = Text15.Value
sourceset!Datefield = ActiveXCtl22.Value
sourceset.Update

sourceset.AddNew
sourceset!Employee_Name = Text137.Value
sourceset!Datefield = ActiveXCtl65.Value
sourceset!Origin = Combo54.Value
sourceset!Stop1 = Combo46.Value
sourceset!Stop2 = Combo48.Value
sourceset!Stop3 = Combo50.Value
sourceset!Stop4 = Combo52.Value
sourceset!Stop1_dist = Text56.Value
sourceset!Stop2_dist = Text58.Value
sourceset!Stop3_dist = Text59.Value
sourceset!Stop4_dist = Text60.Value
sourceset.Update

Exit Sub

error_submit:
If Err.Number = 3022 Then
MsgBox "This record has already been added"
Else
MsgBox Error
End If
 
Hello: Don't you have to Close out the sourceset Like:
rst.Close
Set rst = Nothing
db.Close
Set db = Nothing
msgbox "This record has already been added", vbinformation, "Admin"
Before the Exit Sub
Place your if then statement also before the exit sub statement.
COol
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top