Two things, the original wouldn't work with the DoCmd where you had it. it
didn't do anything. I moved it and OK (see below). But, i am also trying to
trap if there is a duplicate record as it saves. If soI added the message
box. Now that works but if there is no record on the opening form it should
have some special error for that. I deleted the popup that had the generic
action canceled, since i expect few items on the opening form. I'd like to
get these two sets of code to work in concert. can you help a bit more?
Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "mform_Short Sheet1 Query"
stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnIsPartOnShortSheet_Click:
Exit Sub
Err_btnIsPartOnShortSheet_Click:
MsgBox "This Is A Duplicate Record.", vbInformation, "Duplicate Record"
Cancel = True
Resume Exit_btnIsPartOnShortSheet_Click
End Sub
---- Code for OnOpen for opening form ------
Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
MsgBox "This record has been saved." _
, vbInformation, "No Short Sheet Records"
Cancel = True
End If
End Sub
thnaks, again,
Jim
--
Ofer said:
Try this
Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
stDocName = "mform_Short Sheet1 Query"
stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnIsPartOnShortSheet_Click:
Exit Sub
Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click
End Sub
:
i need to add a Save Record function BEFORE the new form opens up. can anyone
add the missing code. i'm not sure how to incorperate it. any help is greatly
appreciated.
Private Sub btnIsPartOnShortSheet_Click()
On Error GoTo Err_btnIsPartOnShortSheet_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "mform_Short Sheet1 Query"
stLinkCriteria = "[WO #]=" & "'" & Me![Work Order:] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_btnIsPartOnShortSheet_Click:
Exit Sub
Err_btnIsPartOnShortSheet_Click:
Resume Exit_btnIsPartOnShortSheet_Click
End Sub
thanks,
jim