NotInList question

JSDART

Registered User.
Local time
Today, 23:28
Joined
Nov 20, 2000
Messages
18
Hi

I am successfully using the following code for the Not In List

Private Sub Meds_NotInList(NewData As String, Response As Integer)
'Add a new Medication by typing a name in the Meds box

Dim intNewMeds As Integer, strTitle As String, intMsgDialog As Integer

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

If intNewMeds = vbYes Then
'Remove new name from Meds so
' control can be requeried when user returns to form.
DoCmd.RunCommand acCmdUndo


'Open Add location form
DoCmd.OpenForm "frm-DRUG NAMES", acNormal, , , acAdd, acDialog, NewData

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

End Sub

My question is the following:

This opens a new form but requires the user to enter the name of the medication twice. any Ideas on how to carry the name of the medication over to the next form so it is only typed once and is the added into the list? I need the safeguard of asking the user if s/he want to add the medication to the list.

Thanks
J
 
As you are already passing the NewData parameter as an OpenArg to the forum you are opening, you can use that form's Form_Load event to place the value in the textbox containing the medication's name.

i.e. (Form Load of new form)

Code:
MyTextBox = Me.OpenArgs
 
still cant get it to work

Thanks for the response I have been trying to gety this to work but no luck.
I placed
Meds = Me.OpenArgs
on the load event of the Medication form but it still opens blank.
whatr am I missing?
Thanks for your help
J
 
JSDART said:
Thanks for the response I have been trying to gety this to work but no luck.
I placed
Meds = Me.OpenArgs
on the load event of the Medication form but it still opens blank.
whatr am I missing?
Thanks for your help
J

In the form properties of the form that you are adding the data to place this in the 'On Open' command

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me.NAMEOFYOURCBO= Me.OpenArgs
End If
End Sub

Steve
 

Users who are viewing this thread

Back
Top Bottom