A somewhat longish thread dealt with exact same issue.
Contents of which betwix *** <Q> *** and *** <UNQ> ***
*** <Q> ***
In yr Client entry form, you use this line:
If Me.Dirty Then Me.Dirty = False
Why do you need this line?
The Client entry form is opened in an acAdd state. If you undo the
changes,
the new record isn't saved.
What happens if you leave out this line?
If the above suggestion fails,
here's a slightly different approach; try to implement
[mainform code)
NotInList() event of the combo fires:
Write the new record to the table
Make sure changes are committed
Pickup the ID of the new record
Set the Response parameter to acDataErrAdded
Open the Client Entry form normally, use a filter or a where
statement
using the ID
[frm 1 Client entry code]
Let the user do the entry of other client info on the form, don't
toggle
the Dirty() property!~
While having a pointer to your mainform (still loaded I presume), you
may need to requery the combo on yr mainform
Set the combo value (on mainform) to the ID you used previously
Close the Client entry form and your back in the mainform with the
new
record selected in the combo
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
"Chris" <
[email protected]> schreef in bericht
Thanks for responding.
I added that line. I also identified the variable (Option Explicit) as
both
String and Integer. Both returned the same results. The message
appears
twice.
I just don't see how its instructed to show twice.
--
Thanks for your help,
Chris
:
Chris,
Befor the Exit Sub of the client entry form place:
response=acdataerrcontinue
--
Maurice Ausum
:
Amateur needs help!
I have a main client form with combo box that selects client.
When client doesn't exist the NotInList code opens an entry form.
When the entry form is complete the user uses a command button to
close
and
return to that record on the main client form.
Everything is as I want, except the message querying whether to add
the
NotInList client appears twice: when its not in the list and again
at
closing
the entry form.
[txtAdding] is a 1 or 0 and is status for use elsewhere.
I cannot see where the problem. Help!
****** code for main client form NotInList ********
Private Sub cboClient_NotInList(NewData As String, Response As
Integer)
Dim Result
Dim msg, CR As String
CR = Chr$(13)
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
' Ask the user if he or she wishes to add the new customer.
NewData = UCase(NewData)
msg = "'" & NewData & "' is not in the list." & CR & CR
msg = msg & "Do you want to add it?"
If Me.txtAdding = 0 Then
If MsgBox(msg, vbQuestion + vbYesNo) = vbYes Then
' If the user chose Yes, start the Client form in
data
entry
Me.txtAdding = 1
DoCmd.OpenForm "frm1 ClientEntry", , , , acAdd,
acDialog,
NewData
Else
Exit Sub
End If
End If
' Look for the client the user created in the Client form.
Result = DLookup("[ClientID]", "[tbl 1 Client]", "[ClientID]='" &
NewData &
"'")
If IsNull(Result) Then
' If the customer was not created, set the Response argument to
suppress
an error message and undo changes.
Response = acDataErrContinue
' Display a customized message.
MsgBox "Please try again!"
Else
' If the customer was created, set the Response argument to
indicate
that
new data is being added.
Response = acDataErrAdded
End If
Me.txtAdding = 0
End Sub
****** code for client entry form closing command button********
Private Sub btnCloseForm_Click()
On Error GoTo Err_btnCloseForm_Click
Dim NewData As String
Dim frm As Form
Set frm = Forms![frm1 client]
NewData = Me.ClientID
If Me.Dirty Then Me.Dirty = False
'closes
entry form and finds new client
Forms![frm1 client].Form!txtAdding = 0
With frm.RecordsetClone
.FindFirst "ClientID=""" & Me.txtClientID & """"
If Not .NoMatch Then frm.Bookmark = .Bookmark
End With
frm.Requery
Set frm = Nothing
DoCmd.GoToRecord acDataForm, "frm1 Client", acNewRec
DoCmd.Close acForm, "frm1 ClientEntry"
Exit_btnCloseForm_Click:
Exit Sub
Err_btnCloseForm_Click:
MsgBox Err.Description
Resume Exit_btnCloseForm_Click
End Sub
--
Thanks for your help,
Chris
--
Thanks for your help,
Chris
*** <UNQ> ***
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
"Chris" <
[email protected]> schreef in bericht
I appreciate your response.
OK...
Main client form:
Combo box to select client's record of choice.
When not in list, OnNotInList queries user if they want to add as new
client.
Affirmative response opens a client entry form.
When information complete the user closes the new client entry form via
button.
Now we are back at the main client form with a complete new client
record
in
the table. The main form at this point remains on the last client
record
selected.
Viewing the list in the combo box reveals the new client is present.
First attempt with added new client:
Selecting that new client at that point does nothing.
Second attempt, freshly added new client:
Selecting any other client first, then selecting the new client results
in
the form returning the first record in the table.
Third attempt, another freshly added new client;
Closing the main form, reopening it, then selecting the new client
works
correctly.
That's why I think its a requery/refresh, combo box or form issue.
Trying requery the combo box in several places (one at a time) results
in
error message 2118, save first. Then I get really lost.
Does that help you to help me?