combining 2 buttons

BadKitty

Registered User.
Local time
Today, 13:34
Joined
Jul 7, 2005
Messages
55
i have a form for users to enter contractor information (when appying for a city permit). on that form, i have a button to open the permit form in add mode & a button to save & close. problem is...when you click the permit button, whatever info was just entered isn't saved yet. rather than having a seperate save button, i'd like to be able to save & open the permit form in 1 click. how do i add code to save the record to the open form button? here's the code to open the form...

Private Sub cmdAddPermit_Click()
On Error GoTo Err_cmdAddPermit_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmPermitOrders"
DoCmd.OpenForm stDocName, , , acFormAdd

Exit_cmdAddPermit_Click:
Exit Sub

Err_cmdAddPermit_Click:
MsgBox Err.Description
Resume Exit_cmdAddPermit_Click

End Sub

this should be simple, but i just can't seem to make it work :o
 
Try this:
Code:
Private Sub cmdAddPermit_Click()
On Error GoTo Err_cmdAddPermit_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmPermitOrders"

[b]If Me.Dirty Then
   '-- Save the current record
   DoCmd.RunCommand acCmdSaveRecord
End If[/b]

DoCmd.OpenForm stDocName, , , acFormAdd

Exit_cmdAddPermit_Click:
Exit Sub

Err_cmdAddPermit_Click:
   [b]MsgBox "Error No:    " & Err.Number & vbCr & _
   "Description: " & Err.Description[/b]
   Resume Exit_cmdAddPermit_Click

End Sub
 
thanx much!

works great. thanx again!
 
You're very welcome and thanks for posting back with your success.
 

Users who are viewing this thread

Back
Top Bottom