Not in List

G

Guest

I have the following codes attached to 2 forms

1. Attached to a combo box on a pop-up bo

Private Sub name_NotInList(NewData As String, Response As Integer

Dim Resul
Dim Msg As Strin
Dim CR As Strin

CR = Chr$(13

If NewData = "" Then Exit Su

Msg = "'" & NewData & "' is not in the list." & CR & C
Msg = Msg & "PS Number not listed. Do you wish to add?
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes The
DoCmd.OpenForm "Overall Information", , , , acAdd, acDialog, NewDat
End I

Result = DLookup("[PS Number]", "PS Numbers",
"[PS Number]='" & NewData & "'"
If IsNull(Result) The
Response = acDataErrContinu
MsgBox "Negative Response!
Els
Response = acDataErrAdde
End I

End Su

2. Attached to the OnLoad property of the main underlying form

Private Sub Form_Load(
If Not IsNull(Me.OpenArgs) The
Me![PS Number] = Me.OpenArg
End I

End Su

Is there any way I can close the initial pop-form without having to resort to using a macro

Similarly, I have another pop-up form which performs the same function as the first pop-up form but refers to a customer supplied ID number (the first pop-up box contains our unique reference numbers). How do I alter the on load section code to transfer this "not in list" data to another field on the main underlying form (specified in 2. above)

Thanking you in antici...patio

Perry Kerr
 
G

Gerald Stanley

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
I have the following codes attached to 2 forms.

1. Attached to a combo box on a pop-up box

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

Dim Result
Dim Msg As String
Dim CR As String

CR = Chr$(13)

If NewData = "" Then Exit Sub

Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "PS Number not listed. Do you wish to add?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbYes Then
DoCmd.OpenForm "Overall Information", , , , acAdd, acDialog, NewData
End If

Result = DLookup("[PS Number]", "PS Numbers", _
"[PS Number]='" & NewData & "'")
If IsNull(Result) Then
Response = acDataErrContinue
MsgBox "Negative Response!"
Else
Response = acDataErrAdded
End If

End Sub

2. Attached to the OnLoad property of the main underlying form.

Private Sub Form_Load()
If Not IsNull(Me.OpenArgs) Then
Me![PS Number] = Me.OpenArgs
End If

End Sub


Is there any way I can close the initial pop-form without
having to resort to using a macro?

I am not sure that I understand your question but if you
want the popup to close automatically after the user has
entered one new record, you can put the following code into
the form's AfterUpdate eventhandler
DoCmd.Close acForm, Me.Name
Similarly, I have another pop-up form which performs the
same function as the first pop-up form but refers to a
customer supplied ID number (the first pop-up box contains
our unique reference numbers). How do I alter the on load
section code to transfer this "not in list" data to another
field on the main underlying form (specified in 2. above).

I do this by making the first character of OpenArgs a
'process type'. By way of example, the DoCmd.OpenForm line
would be changed to
DoCmd.OpenForm "Overall Information", , , , acAdd,
acDialog, "A" & NewData

and the Load eventHandler changed to

If Not IsNull(Me.OpenArgs) Then
If Left(Me.OpenArgs, 1) = "A" Then
Me![PS Number] = Mid(Me.OpenArgs,2)
Else
some other field = Mid(Me.OpenArgs,2)
End If
End If

The other call to open this popup would need to changed to
put in a first character other than A
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top