UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Notinlist Event Struggles, Access 2016    
 
   
Consonanza
post Feb 16 2017, 11:36 AM
Post#1



Posts: 131
Joined: 1-June 10



In a field on my subform I have standard code for the "Not in List" event for my combo (cboMusicTitle). As well as being able to enter the new music title, I want to be able to add some related details for the new record, so in the code I open the existing form that I use to maintain the related data. This is the code:

CODE
Private Sub cboMusicID_NotInList(NewData As String, Response As Integer)
' Add a new entry by typing a name in the box.
Dim intNewEntry As Integer, strTitle As String, intMsgDialog As Integer

' Display message box asking if user wants to add a new music work.
    strTitle = "Entry Not In List"
    intMsgDialog = vbYesNo + vbQuestion + vbDefaultButton1
    intNewEntry = MsgBox("Do you want to add a new Music Work?", intMsgDialog, strTitle)


If intNewEntry = vbYes Then
        ' Remove new name from ID combo box so
        ' control can be requeried when user returns to form.
        DoCmd.RunCommand acCmdUndo

        ' Open Music Works form.
        DoCmd.OpenForm "frmMusicWorks", acNormal, , , acAdd, acDialog, NewData

        ' Continue without displaying default error message.
        Response = acDataErrAdded
    End If
End Sub


The problem is that I want to have the value I entered in the combo box appear in the relevant form field (fldMusicTitle) when frmMusicWorks opens.

I have tried placing Me!fldMusicTitle = NewData in the various events of frmMusicWorks (On Open, On Current, On Load) but nothing works. Where am I going wrong?
Go to the top of the page
 
BruceM
post Feb 16 2017, 11:52 AM
Post#2


UtterAccess VIP
Posts: 6,563
Joined: 24-May 10
From: Downeast Maine


NewData is being passed to frmMusicWorks as the OpenArgs value. NewData is specific to the Not In List event, and loses its scope as soon as you leave the event, but its value can be passed to the form being opened as long as you define it properly. I think you need to do something like the following in the frmMusicWorks Load event. Use the actual text box name instead of txtMusicTitle.

CODE
If Not IsNull(Me.OpenArgs) Then
    Me.txtMusicTitle = Me.OpenArgs
End If
Go to the top of the page
 
Consonanza
post Feb 16 2017, 12:32 PM
Post#3



Posts: 131
Joined: 1-June 10



Exactly right! Thanks so much.


This post has been edited by Consonanza: Feb 16 2017, 12:33 PM
Go to the top of the page
 
BruceM
post Feb 16 2017, 12:41 PM
Post#4


UtterAccess VIP
Posts: 6,563
Joined: 24-May 10
From: Downeast Maine


Glad to help! Good luck with the project.
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    24th June 2017 - 08:54 AM