oxicottin
Learning by pecking away....
- Local time
- Today, 08:39
- Joined
- Jun 26, 2007
- Messages
- 851
Hello, I have a button cmdAddNewSubFormPage on my subform that that creates a record adds the next sequential number in txtSequentialNumber and then opens a popup frm_ManageSubMenuPage. I wanted to somehow use OpenArgs to open the popup BUT not create the record yet incase you decide not to go threw with creating one. The way it is now is it creates a record then opens the popup form. How else can I do this?
Code:
Private Sub cmdAddNewSubFormPage_Click()
'--------------------------------------------------------------------------------------------------
'Helped: thedbguy@gmail.com 9/25/20 _
by adding Nz(Me.Parent.cboMenuPage, 0)
'
'Purpose: Was getting error because there want a MenuID created yet so in order to supress the error _
it grabs the MenuID from the parent forms combo box cboMenuPage for the string.
'--------------------------------------------------------------------------------------------------
Dim strNxtNum As String
Dim intMaxNumRecs As Integer
strNxtNum = DMax("MenuSequentialNumber", "tbl_MenuItems", "[MenuID] = " & Nz(Me.Parent.cboMenuPage, 0)) + 1
intMaxNumRecs = 9 'Max Number of Records to Allow
If Me.Recordset.RecordCount >= intMaxNumRecs Then
MsgBox "You cant have more than 9 SubMenu Entries for this Menu Page.", vbInformation, "Over Max"
Exit Sub
End If
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
txtSequentialNumber = strNxtNum
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acLast
Me.AllowAdditions = False
'Open the frm_ManageSubMenuPage
cmdEditSubMenuPage_Click
End Sub
Private Sub cmdEditSubMenuPage_Click()
If IsNull(Me.txtRowMenuID) Or Me.txtRowMenuID = "" Then
MsgBox "You cant edit a SubMenu until you add one first", vbInformation, "Missing Data"
Me.cmdAddNewSubFormPage.SetFocus
Exit Sub
End If
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "frm_ManageSubMenuPage"
stLinkCriteria = "[MenuID]=" & Me.txtMenuID & "And [MenuSequentialNumber]=" & Me.txtSequentialNumber
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit
End Sub