A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Combo Search issues



 
 
Thread Tools Display Modes
  #1  
Old April 7th, 2008, 09:14 PM posted to microsoft.public.access.forms
Lori
external usenet poster
 
Posts: 95
Default Combo Search issues

Okay here's the issue. On one form I have two search fields set up one to
search by name and another to search by project number. After Update they
work beautifully to move the user to the correct project. the code for these
are as follows:

Private Sub cboProject_AfterUpdate()

DoCmd.GoToRecord
Me!JobName.SetFocus
DoCmd.FindRecord Me!cboProject

'Set value of combo box equal to an empty string
Me!cboProject.Value = ""
End Sub

Private Sub CboProjectNo_AfterUpdate()

DoCmd.GoToRecord
Me!Project.SetFocus
DoCmd.FindRecord Me!CboProjectNo

'Set value of combo box equal to an empty string
Me!CboProjectNo.Value = ""
End Sub


As I said these work beautifully however here is the problem. If a user
searches for a specific project (regardless of whether it is by name or
number) they can easily move to the next project UNLESS they make a change
and update the current record. If they update a record and then try to move
to the next record they receive an error stating that "You Can't Go to the
Specified Record." If an attempt is made to search for the next record, it
will search fine but it will not go to the new search item. The user gets a
Run Time Error that states "You Can't Go to the Specified Record" and it
gives them the option to debug.

How do we get around this? Is it essential that they close the form after
every search that requires an update?
--
Lori A. Pong
  #2  
Old April 7th, 2008, 09:54 PM posted to microsoft.public.access.forms
Golfinray
external usenet poster
 
Posts: 1,597
Default Combo Search issues

I would try to save the record as soon as it is updated, either with code or
a command button. It probably doesn't want to go to the next record until the
current record, and any changes, is saved.

"Lori" wrote:

Okay here's the issue. On one form I have two search fields set up one to
search by name and another to search by project number. After Update they
work beautifully to move the user to the correct project. the code for these
are as follows:

Private Sub cboProject_AfterUpdate()

DoCmd.GoToRecord
Me!JobName.SetFocus
DoCmd.FindRecord Me!cboProject

'Set value of combo box equal to an empty string
Me!cboProject.Value = ""
End Sub

Private Sub CboProjectNo_AfterUpdate()

DoCmd.GoToRecord
Me!Project.SetFocus
DoCmd.FindRecord Me!CboProjectNo

'Set value of combo box equal to an empty string
Me!CboProjectNo.Value = ""
End Sub


As I said these work beautifully however here is the problem. If a user
searches for a specific project (regardless of whether it is by name or
number) they can easily move to the next project UNLESS they make a change
and update the current record. If they update a record and then try to move
to the next record they receive an error stating that "You Can't Go to the
Specified Record." If an attempt is made to search for the next record, it
will search fine but it will not go to the new search item. The user gets a
Run Time Error that states "You Can't Go to the Specified Record" and it
gives them the option to debug.

How do we get around this? Is it essential that they close the form after
every search that requires an update?
--
Lori A. Pong

  #3  
Old April 8th, 2008, 01:56 AM posted to microsoft.public.access.forms
Boyd Trimmell aka HiTechCoach
external usenet poster
 
Posts: 9
Default Combo Search issues

To force the record to be saved before the find, try something like:

Private Sub cboProject_AfterUpdate()

' save the record if changed
If Me.Dirty Then Me.Dirty = False

DoCmd.GoToRecord
Me!JobName.SetFocus
DoCmd.FindRecord Me!cboProject

'Set value of combo box equal to an empty string
Me!cboProject.Value = ""

End Sub


--
Boyd Trimmell aka HiTech Coach
http://www.officeprogramming.com
http://www.hitechcoach.com


"Lori" wrote:

Okay here's the issue. On one form I have two search fields set up one to
search by name and another to search by project number. After Update they
work beautifully to move the user to the correct project. the code for these
are as follows:

Private Sub cboProject_AfterUpdate()

DoCmd.GoToRecord
Me!JobName.SetFocus
DoCmd.FindRecord Me!cboProject

'Set value of combo box equal to an empty string
Me!cboProject.Value = ""
End Sub

Private Sub CboProjectNo_AfterUpdate()

DoCmd.GoToRecord
Me!Project.SetFocus
DoCmd.FindRecord Me!CboProjectNo

'Set value of combo box equal to an empty string
Me!CboProjectNo.Value = ""
End Sub


As I said these work beautifully however here is the problem. If a user
searches for a specific project (regardless of whether it is by name or
number) they can easily move to the next project UNLESS they make a change
and update the current record. If they update a record and then try to move
to the next record they receive an error stating that "You Can't Go to the
Specified Record." If an attempt is made to search for the next record, it
will search fine but it will not go to the new search item. The user gets a
Run Time Error that states "You Can't Go to the Specified Record" and it
gives them the option to debug.

How do we get around this? Is it essential that they close the form after
every search that requires an update?
--
Lori A. Pong

  #4  
Old April 8th, 2008, 03:21 AM posted to microsoft.public.access.forms
Linq Adams via AccessMonster.com
external usenet poster
 
Posts: 1,474
Default Combo Search issues

I'm not sure that it has anything to do with your problem, but the line

DoCmd.GoToRecord

that appears in both of your subs isn't doing anything, as you're not telling
Access what record to go to with it. I'd try commenting them out for now.

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200804/1

  #5  
Old April 8th, 2008, 01:34 PM posted to microsoft.public.access.forms
Lori
external usenet poster
 
Posts: 95
Default Combo Search issues

HELP!!!

I've tried all three suggestions, I tried code to save after a change is
made, I've tried including a new button to save the record and I've tried the
code suggested by Linq. Nothing helps.

I've also tried to refresh the form hoping that it would clear the initial
search. Nothing works.

Any other ideas would be appreciated.
--
Lori A. Pong


"Boyd Trimmell aka HiTechCoach" wrote:

To force the record to be saved before the find, try something like:

Private Sub cboProject_AfterUpdate()

' save the record if changed
If Me.Dirty Then Me.Dirty = False

DoCmd.GoToRecord
Me!JobName.SetFocus
DoCmd.FindRecord Me!cboProject

'Set value of combo box equal to an empty string
Me!cboProject.Value = ""

End Sub


--
Boyd Trimmell aka HiTech Coach
http://www.officeprogramming.com
http://www.hitechcoach.com


"Lori" wrote:

Okay here's the issue. On one form I have two search fields set up one to
search by name and another to search by project number. After Update they
work beautifully to move the user to the correct project. the code for these
are as follows:

Private Sub cboProject_AfterUpdate()

DoCmd.GoToRecord
Me!JobName.SetFocus
DoCmd.FindRecord Me!cboProject

'Set value of combo box equal to an empty string
Me!cboProject.Value = ""
End Sub

Private Sub CboProjectNo_AfterUpdate()

DoCmd.GoToRecord
Me!Project.SetFocus
DoCmd.FindRecord Me!CboProjectNo

'Set value of combo box equal to an empty string
Me!CboProjectNo.Value = ""
End Sub


As I said these work beautifully however here is the problem. If a user
searches for a specific project (regardless of whether it is by name or
number) they can easily move to the next project UNLESS they make a change
and update the current record. If they update a record and then try to move
to the next record they receive an error stating that "You Can't Go to the
Specified Record." If an attempt is made to search for the next record, it
will search fine but it will not go to the new search item. The user gets a
Run Time Error that states "You Can't Go to the Specified Record" and it
gives them the option to debug.

How do we get around this? Is it essential that they close the form after
every search that requires an update?
--
Lori A. Pong

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 09:07 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.