PC Review


Reply
Thread Tools Rate Thread

Access VBA DAO Find routine on Form Combobox

 
 
=?Utf-8?B?TWF0dCBTbGF0dGVyeQ==?=
Guest
Posts: n/a
 
      20th Jun 2005
I have a standard "Find" routine triggered by the AfterUpdate event on an
Unbound Form Combobox.
Code as follows:

Sub cboGoto_AfterUpdate()
Dim rs as Recordset
Set rs = Me.RecordsetClone
rs.FindFirst "[JobNo] = " & Me.cboGoto
Me.Bookmark = rs.Bookmark
Set rs = Nothing
End Sub

This event has been working perfectly for several months and has suddenly
stopped working in a certain DB. The exact same code runs smoothly in other
DB's without a problem.

Notes:
The field in question is a numeric data type.
The event procedure does actually run, but it always goes to the first
record in the form, rather than to the record it should find.
The numbers in the combobox can always be found in the destination field.
All other routines in the DB run fine

The DB in question is a Front / Back end setup in Access 2000 File Format
All clients are running Access 2003 + WinXP Pro with latest updates / patches

Without solving the problem, I have:
Tried the "combobox wizard" to "Find a record on my form based on the value
I selected in my combobox".
Recreated the combobox and the event code from scratch.
Recompiled the DB.
Imported all objects into a new DB file.
Tried previous DAO Libraries + used both Early and Late binding versions of
the event procedure.

I am at wits end for what would seem to be such a simple problem.

I am VERY curious to see if anybody else has experienced similar problems or
if anybody has any ADODB code to goto a specific record on a form based on a
combobox selection.

My kindest thanks to anybody who can help shed light on this situation

Regards,
Matt Slattery
 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      20th Jun 2005
Matt, this should work, and the steps you have taken make good sense.

Try the code from this link in the combo's AfterUpdate:
http://allenbrowne.com/ser-03.html
Improvements over the wizard-generated code include:
- Forcing the save the the existing record (avoid some bugs associated with
clearing hanging event queue before trying to move);
- Testing NoMatch, and indicating if something went wrong, instead of
assuming it worked.

Presumably you have also tried a repair (Tools | Databse Utilities |
Repair), and if so, that should have repaired any corrupt index.

Is there any chance that Access is finding the right record, but something
else is changing it afterwards? You could see that happening if you add a
breakpoint (F9) and then single-step through the code (F8).

You say the field is a Number type. Not Decimal type by any chance? JET
cannot handle that type correctly.

Presumably Name AutoCorrect is off? Otherwise Access is likely to get
confused and refer to the wrong things. More info:
http://allenbrowne.com/bug-03.html

You say you have applied all the patches. I think it's worth double-checking
that there is only one copy of msjet40.dll anywhere on path, and that it is
version 4.0.8xxx.0 (Properties of the file when you find it in My Computer.)

How many records are in the combo's RowSource when this error occurs?

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Matt Slattery" <Matt (E-Mail Removed)> wrote in message
news:4FBB3BC2-36F1-4C5B-A720-(E-Mail Removed)...
>I have a standard "Find" routine triggered by the AfterUpdate event on an
> Unbound Form Combobox.
> Code as follows:
>
> Sub cboGoto_AfterUpdate()
> Dim rs as Recordset
> Set rs = Me.RecordsetClone
> rs.FindFirst "[JobNo] = " & Me.cboGoto
> Me.Bookmark = rs.Bookmark
> Set rs = Nothing
> End Sub
>
> This event has been working perfectly for several months and has suddenly
> stopped working in a certain DB. The exact same code runs smoothly in
> other
> DB's without a problem.
>
> Notes:
> The field in question is a numeric data type.
> The event procedure does actually run, but it always goes to the first
> record in the form, rather than to the record it should find.
> The numbers in the combobox can always be found in the destination field.
> All other routines in the DB run fine
>
> The DB in question is a Front / Back end setup in Access 2000 File Format
> All clients are running Access 2003 + WinXP Pro with latest updates /
> patches
>
> Without solving the problem, I have:
> Tried the "combobox wizard" to "Find a record on my form based on the
> value
> I selected in my combobox".
> Recreated the combobox and the event code from scratch.
> Recompiled the DB.
> Imported all objects into a new DB file.
> Tried previous DAO Libraries + used both Early and Late binding versions
> of
> the event procedure.
>
> I am at wits end for what would seem to be such a simple problem.
>
> I am VERY curious to see if anybody else has experienced similar problems
> or
> if anybody has any ADODB code to goto a specific record on a form based on
> a
> combobox selection.
>
> My kindest thanks to anybody who can help shed light on this situation
>
> Regards,
> Matt Slattery



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I get form name / routine name from Access? Dennis Microsoft Access Form Coding 5 28th Dec 2009 05:49 AM
How can I find out the name of the routine that is currently running? Mr.Magic Microsoft C# .NET 12 19th Oct 2009 05:37 PM
access 2007 form combobox not working -Karl Microsoft Access Forms 1 16th Jul 2009 11:11 PM
Re: Please help me with updating a form combobox (or table field) based on the choice of a different form combobox Ken Snell \(MVP\) Microsoft Access Forms 0 8th Oct 2007 12:37 AM
Find record using combobox in ADP form =?Utf-8?B?RGFu?= Microsoft Access Form Coding 1 20th Apr 2005 04:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:41 PM.