OpenArgs problem

potts

Registered User.
Local time
Today, 00:03
Joined
Jul 24, 2002
Messages
87
I have been using the following code to update information populating a combo box, e.g. if I enter "eggs" and it is not a stored term, I get asked if I want to add it, and then the combo box is updated accordingly.

'In the data entry form ...

Private Sub JournalID_NotInList(NewData As String, Response As Integer)

If vbYes = MsgBox("The journal '" & NewData & "' is not in the journal list. " & _
" Do you want to add it?", vbQuestion + vbYesNo) Then
DoCmd.OpenForm "frmSource", acNormal, , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
Else
Response = acDataErrDisplay
End If

End Sub



'In the "frmSource" form ...

Private Sub Form_Load()
If Not IsNothing(Me.OpenArgs) Then
Me!Journal = Me.OpenArgs
Me.SetFocus
DoCmd.Close
End If
End Sub



This has worked fine for me on a number of occasions. However, I now need to update two fields in the frmSource form and I can't get it to work.

I have tried removing the DoCmd.Close line, entering the data in the second field manually and then closing the form, but although the underlying table of "frmSource" is updated, the combo box on the data entry form is not updated unless I close the form and open it again.


Does anyone know how I might fix this?
 
Code:
Private Sub JournalID_NotInList(NewData As String, Response As Integer) 

If vbYes = MsgBox("The journal '" & NewData & "' is not in the journal list. " & _ 
" Do you want to add it?", vbQuestion + vbYesNo) Then 
DoCmd.OpenForm "frmSource", acNormal, , , acFormAdd, acDialog, NewData 
Response = acDataErrAdded 
Else 
Response = acDataErrDisplay 
End If 

[b]Me.JournalID.Requery[/b]

End Sub
 
I finally got this to work using the code you posted-Thanks!

But, do you know why, when my NotInList message appears, I click on Yes, the message automatically pops up again for some reason, I click Yes again, and my new form opens correctly-

Any ideas???

Toni
 

Users who are viewing this thread

Back
Top Bottom