Requery (?) issue.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I think this is my problem.

I add a client not in my client combo list, then open a new form for that
client to enter extended information. This works fine.

However, I want to return to the client I have just added on my main form
and its giving me fits.

The new client shows in my combo box list. Double clicking will do nothing
while others are double click-able. If I open another client before
attempting to open the newly established client, my cbo list returns the
first record. If I close the form, when I reopen my world is good again.

I think this to be a requery issue, but have run into error 2118 save first
message. Killing me!

I assume code would go into the OnClose, OnUnload or my closing command
button -- but I lack the skill to asses the bottom-line issue. Very much a
learning mode here.

I appreciate all help; especially the solution.
 
Are you refering to "NotInList()" event?

If so, you have to indicate the entire sequence of events.
From what you're telling now: it's a bit unclear.

Pls elaborate.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
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?

--
Thanks for your help,
Chris


Perry said:
Are you refering to "NotInList()" event?

If so, you have to indicate the entire sequence of events.
From what you're telling now: it's a bit unclear.

Pls elaborate.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
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: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 said:
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


Maurice said:
Chris,

Befor the Exit Sub of the client entry form place:
response=acdataerrcontinue
--
Maurice Ausum


Chris said:
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

*** <UNQ> ***




--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



Chris said:
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?
 
That would be your earlier suggestion in another post of mine to eliminate a
message appearing twice. As I responded to your last over at that message, I
used your suggestions and managed somehow to get to the point I am now --
unable to return to the new client record.

Granted, as an amateur I don't see things as readily. I have winnowed the
double-message issue to one of inability of the user to "land" on the new
client's record after all client data is entered.

I am unable to see this solution in the prior postings. If it is, in fact,
the same issue please explain it to me.

I appreciate your time and help.

--
Thanks for your help,
Chris


Perry said:
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: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 said:
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


Maurice said:
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

*** <UNQ> ***




--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
 
unable to return to the new client record.

Important:
Let's get one thing straight: you've eliminated the duplicate warning and
you are now
stuck to the combo not presenting the correct (new) entry, right?
Pls confirm?

If so, could you kick in the new code you got, regarding bringing up the
Client Entry form
and the relevant code closing the Client Entry form?

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



Chris said:
That would be your earlier suggestion in another post of mine to eliminate
a
message appearing twice. As I responded to your last over at that
message, I
used your suggestions and managed somehow to get to the point I am now --
unable to return to the new client record.

Granted, as an amateur I don't see things as readily. I have winnowed the
double-message issue to one of inability of the user to "land" on the new
client's record after all client data is entered.

I am unable to see this solution in the prior postings. If it is, in
fact,
the same issue please explain it to me.

I appreciate your time and help.

--
Thanks for your help,
Chris


Perry said:
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 said:
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

*** <UNQ> ***




--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



Chris said:
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?

--
Thanks for your help,
Chris


:

Are you refering to "NotInList()" event?

If so, you have to indicate the entire sequence of events.
From what you're telling now: it's a bit unclear.

Pls elaborate.

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



"Chris" <[email protected]> schreef in bericht
I think this is my problem.

I add a client not in my client combo list, then open a new form for
that
client to enter extended information. This works fine.

However, I want to return to the client I have just added on my main
form
and its giving me fits.

The new client shows in my combo box list. Double clicking will do
nothing
while others are double click-able. If I open another client before
attempting to open the newly established client, my cbo list returns
the
first record. If I close the form, when I reopen my world is good
again.

I think this to be a requery issue, but have run into error 2118
save
first
message. Killing me!

I assume code would go into the OnClose, OnUnload or my closing
command
button -- but I lack the skill to asses the bottom-line issue. Very
much
a
learning mode here.

I appreciate all help; especially the solution.
 
Yes, I confirm that. The new client does appear in the combo box. I just
cannot do anything with it unless and until I close the form it is on and
reopen it. Then I can select the new client.

All I am trying to do is -- upon closing my detail entry form return to the
main form at the record of the new client. I have assumed because of the
aforementioned behavior that my issue was requery. I further assumed once I
understood why I could not requery the combo box without an error 2118 about
saving first that I would be able to load some code in the closing routine of
the detail entry form to select the new client's record for the main form.

Main client form not in list code:
Private Sub cboClient_NotInList(NewData As String, response As Integer)
Dim Result
Dim msg As String
Dim CR As String

CR = Chr$(13)
' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub
NewData = UCase(NewData)

' Ask the user if he or she wishes to add the new client.
msg = "'" & NewData & "' is not in the list." & CR & CR
msg = msg & "Do you want to add this new client?"

If MsgBox(msg, vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
' If the user chose Yes, start the NewClient form in data entry mode
as a dialog form,
' passing the new client id in NewData to the OpenForm method's
OpenArgs argument. The
' OpenArgs argument is used in client form's Form_Load event
procedure.
DoCmd.OpenForm "frm1 ClientEntry", , , , acAdd, acDialog, NewData
End If

' Look for the client the user created in the NewClient form.
Result = DLookup("[ClientID]", "tbl 1 CLIENT", "[ClientID]='" & NewData & "'")

If IsNull(Result) Then
' If the client was not created, set the Response argument to
suppress an error
' message and undo changes.
response = acDataErrContinue
MsgBox "The client record WAS NOT created."
Else
' If the client was created, set the Response argument to indicate
that new data
' is being added.
response = acDataErrAdded
MsgBox "The client record WAS created"
End If
End Sub

Client entry form closing code (command button):
Private Sub btnCloseForm_Click()
DoCmd.Close
End Sub

I removed all the code from the closing button to start over; I was going in
twelve different directions.

--
Thanks for your help,
Chris


Perry said:
unable to return to the new client record.

Important:
Let's get one thing straight: you've eliminated the duplicate warning and
you are now
stuck to the combo not presenting the correct (new) entry, right?
Pls confirm?

If so, could you kick in the new code you got, regarding bringing up the
Client Entry form
and the relevant code closing the Client Entry form?

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



Chris said:
That would be your earlier suggestion in another post of mine to eliminate
a
message appearing twice. As I responded to your last over at that
message, I
used your suggestions and managed somehow to get to the point I am now --
unable to return to the new client record.

Granted, as an amateur I don't see things as readily. I have winnowed the
double-message issue to one of inability of the user to "land" on the new
client's record after all client data is entered.

I am unable to see this solution in the prior postings. If it is, in
fact,
the same issue please explain it to me.

I appreciate your time and help.

--
Thanks for your help,
Chris


Perry said:
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?
 
Thanks for the help. I've managed to get it done.
--
Thanks for your help,
Chris


Perry said:
unable to return to the new client record.

Important:
Let's get one thing straight: you've eliminated the duplicate warning and
you are now
stuck to the combo not presenting the correct (new) entry, right?
Pls confirm?

If so, could you kick in the new code you got, regarding bringing up the
Client Entry form
and the relevant code closing the Client Entry form?

--
Krgrds,
Perry

System:
Vista/Office Ultimate
VS2005/VSTO2005 SE



Chris said:
That would be your earlier suggestion in another post of mine to eliminate
a
message appearing twice. As I responded to your last over at that
message, I
used your suggestions and managed somehow to get to the point I am now --
unable to return to the new client record.

Granted, as an amateur I don't see things as readily. I have winnowed the
double-message issue to one of inability of the user to "land" on the new
client's record after all client data is entered.

I am unable to see this solution in the prior postings. If it is, in
fact,
the same issue please explain it to me.

I appreciate your time and help.

--
Thanks for your help,
Chris


Perry said:
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?
 
Back
Top