473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with FindFirst, Access 2002

Hello everyone,

In an Access 2002 database I have the following setup:

On a Form there is a List Box on which records can be viewed and selected. When a user selects a record it can be modified by using Combo Boxes or Text Boxes on the Form to modify the record.

On the table associated with the Form I had to change the properties of 1 column. The properties changed were:
  • From the column being Required to not being Required
  • From the column being Indexed Yes (No Duplicates) to not being indexed
  • Removing the Primary Key and re-assigning the Primary Key to a new column with AutoNumber

The change was done to allow duplicate data on the column. After the change when a user enters duplicate data it is entered into the table just fine but when the new record with duplicate data is selected again (ie: for editing) the data displayed in the Combo and Text boxes is not of the record selected in the List box but rather the first record to have had original data entered. Because of this behavior the user cannot edit the record they have selected.

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. Sub List35_AfterUpdate()
  2.     ' Find the record that matches the control.
  3.     Me.RecordsetClone.FindFirst "[License] = '" & Me![List35] & "'"
  4.     Me.Bookmark = Me.RecordsetClone.Bookmark
  5. End Sub
I have tried replacing the table with a new identical table but the behavior still occurs. I am guessing there is something wrong with the Form but I am not sure where else to look.

Any ideas?

Thanks.
Jun 22 '11 #1

✓ answered by Stewart Ross

Hi. The License Number field was previously a text type; the autonumber field is a whole number. The type mismatch arises from the use of the text delimiter apostrophes that were formerly used for the license number - remove these as in the example below:

Expand|Select|Wrap|Line Numbers
  1. Me.RecordsetClone.FindFirst "[Record] = " & Me![List35]
-Stewart

4 2650
Stewart Ross
2,545 Expert Mod 2GB
As you have found, FindFirst (as its name suggests) just finds the first occurrence of the given value. That was fine when license values were unique, but you have now changed this so that duplicates are allowed.

How do you distinguish the 'correct' record from a user's point of view? Forgetting the autonumber primary key for a moment (as sequence numbers are not normally meaningful from a user's point of view), what can you supply to your FindFirst that will pick up the record you want to find? Even if you were to use 'movenext' to walk through each record in the recordset after using findfirst to find the very first match, you would need some criterion to know which record to stop upon.

If you can identify an additional field to search upon you can modify the findfirst to find the combination of fields accordingly, like this (with a renewal date assumed in this example):

Expand|Select|Wrap|Line Numbers
  1. Me.RecordsetClone.FindFirst "[License] = '" & Me![List35] & "' AND [Last Renewal Date] = #" & Format(Me.[List35].Column1, """mm/dd/yyyy""" & "#"
Of course, if you can identify the proper record from a user's point of view you can then devise a query that would include the proper primary key, which can be fed to the FindFirst in place of the License number field used at present.

If you could advise what potential field or fields you can use in combination with the license number we can advise further on how to search for the combination (and how to include the field concerned in your list box).

-Stewart
Jun 22 '11 #2
Thank you Stewart for helping me with this.

After reading your response I decided to change the Form again so that FindFirst would be focused on a column with unique data like you suggested. Unfortunately the only unique data per record is the column with AutoNumber set. I agree with you this column will be meaningless to the user’s entering data but if it will make the form work properly then I think it’s worth to try to use it. It is also the column to which the Primary Key is set to.

So on the List Box properties, in the “Format” Tab, I increased the “Column Count” by 1, I specified the width of the column to 0.01” (this way it just looks like double lines to the user), and I added the name of the column under the “Data” Tab in the “Row Source” Field with the flowing text: SELECT DISTINCTROW [MTO Fax].[Record], [MTO Fax].[License], … (more non-unique columns follow). The “Bound Column” is 1 for the number 1 column. Finally in the Form’s code I changed the FindFirst criteria from “License” to “Record”.

When I test I get the following message:
Run-time error ‘3464’:

Data type mismatch in criteria expression.
Can you tell me what's going on now after this new change?

Also, just in case FindFirst does not like the column that contains the Primary Key, I tried to create a new column with AutoNumber set but Access says it only allows one column with AutoNumber set per table.

The table by the way, which is for inventorying software, does not contain records that are unique. The fields include Name, Description, License and PC Name. Data will be repeated in multiple records, for example if 2 people share a license for one piece of software.

Any ideas? Thanks again for helping out.
Jun 23 '11 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi. The License Number field was previously a text type; the autonumber field is a whole number. The type mismatch arises from the use of the text delimiter apostrophes that were formerly used for the license number - remove these as in the example below:

Expand|Select|Wrap|Line Numbers
  1. Me.RecordsetClone.FindFirst "[Record] = " & Me![List35]
-Stewart
Jun 23 '11 #4
Thank you Stewart, that took care of it. It works perfect now.

Thank you for your help.

-Armando.
Jun 24 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: John | last post by:
Hi, I've recently upgraded from Access 97 to Access 2002 & the performance basically stinks. I have tried the following items listed below but it has only had a minor impact: 1) Upgraded Jet...
7
by: Wayne Aprato | last post by:
I have several Access 2003 mde databases. When I try to open them in Access 2002 I get the following error: "The Visual Basic for Applications project in the database is corrupt." ...
4
by: Esmee | last post by:
Hi there, Hope you guys can help me out. For one of my clients I have created an Access 2002 db. It used to be under Access97, but I have converted it to Access 2002, without any problems. My...
5
by: Lakbir Dhillon | last post by:
We converted our databases from Access 97 to Access 2002 (only the MDB files, not the MDW file). In addition we ported the Access application from a Citrix NT server to a Citrix XP server. We...
8
by: David Kistner | last post by:
I'm fairly new to Access (I've worked with Oracle and MySQL in the past). I was asked to build an application for a small office and told that I had to use Access 2002. I was VERY uncomfortable...
4
by: sea | last post by:
I have a database in Access 2002 but I am unable to view code or write any modules when logged in with a limited user account using Windows XP, service pack 2 -- no problems when logging in as...
3
by: mar10 | last post by:
I am creating a database in Access 2002 for a small firm that would like security on the tables. They want some employees to have write access only to tables, while others read-only. I have not...
2
by: SKarnis | last post by:
We are trying to rebuild a current Access 2002 (XP) mdb program to VB.NET with a SQL database - we are having problems with a suitable combobox. There are many threads discussing multiple column...
2
by: Frav | last post by:
The Reps team have been experiencing that Access 2002 unexpectedly quits while working and also lots of Corruption Failures and "Record lock can not update" messages since the upgrade from...
0
by: Sebastian | last post by:
Hello I develop my applications in Access 2002. My development system is running Windows XP SP2 and I have Microsoft Office XP Developer. Microsoft Office XP is at SP3. I used Inno Setup (great...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.