Sub form and form shows wrong search result

I’m in version 7.3.5.2. When I search in a form for an ID # both the sub-form and form shows the record # after the one I am searching for. The problem starts at record #349 which I deleted. The ID sequence now goes from 348 to 350. When I search from record 1-348 all is good. After that any search beyond 349 brings up the next record.

I thought that it would be okay to delete a record without creating this issue.

Thanks, Mike

ID isn’t the same as row numbering.

Please add 2 screenshots, one with value you will search and one with the wrong record.

Also: Add the database you use. There are different possibilities to get the row number for internal Firebird and internal HSQLDB.

Search value
Capture

Wrong record
Capture_2

Contacts.odb (183.4 KB)

As @RobertG already guessed: The place where you look doesn’t show the Id, but a row-number of the current set.
.
You could change the sorting and would see different records at position 1.
.
Also: This is no search. If your Ids start with 10000 you would maybe have 10350 in line 349. Same for non-integer IDs.

I’m new to the software. What would I need to do to correct this in steps? If you don’t mind telling me. I think your saying that I have not set up the ID field correctly.

Nothing wrong with your id.
.
Compare it to a library. One book is damaged and will be givven away. Now you may delete also the the data in your database, wich leaves a hole in your sequece of ids. Would you relabel all books with higher ids? Usually you don’t.
.
So I suggest to accept the holes in the sequence of ids. To find a special id use a filter.

1 Like

You will get the right RowNumber this way:

SELECT "a".*, (SELECT COUNT("ID") FROM "Contacts" WHERE "ID" <= "a"."ID") AS "RowNr" FROM "Contacts" AS "a"

Add this code as query and it will show the right numbers of rows depending of the sorting of “ID”.

Thanks, Robert. I entered the query. Would this be a correct result when searching?

It isn’t searching, but: You will see the “ID” above. You won’t need this “ID” - hope it is created as AutoValue.
Open the form for editing.
Switch datasource for the form to the query.
Click on “ID” (might be you choose 2 fields, then press CTRL while clicking).
Open control properties by right mouse click and change the label to “RowNr” (or something else - not “ID”).
Then open the same way control properties for the input field for “ID”.
Switch data source to “RowNr”.
Now you will get the same number for your row in the form control and in the counter if you won’t sort the content of a different way …
Contacts.odb (183.5 KB)

Am I in the right place?

Yes - now you have to choose the query. But you could also see this in the attached database. I have changed the form this way and uploaded it.

I think I figured it out! I’m getting the same number for the row in the form control and in the counter.

I didn’t realize that you made all of the changes in your uploaded file. My taskbar shortcut kept pointing to the old file and it was confusing me. Not hard to do these days!

Thank you for the help.

Now that the row count is working properly, I came across another issue which seems to be the result of the changes made yesterday. I’m using the @RobertG uploaded file.

A phone number in the form that used to show (999)030-0300 is now shown as 9990300300.

Mike

You have defined the fields for phone numbers as numeric fields. So you could only save numbers. Numeric fields might be wrong for phone numbers, because it is also impossible to write this “number” with leading ‘0’. Characters like (, ), - or a space are impossible in a field for numbers.

Why the change after your fix yesterday? Something must have changed the way the phone numbers are now being displayed. I didn’t change any formatting of the phone # fields.

You have created a special format for the numeric value in your table. It will use this format code: (000")-"000"-"0000. The query doesn’t read this code and couldn’t save any special codes. The field in the form should do this now, if you really want it. It is a code, special for 10 numbers - won’t work with leading ‘0’, also won’t work for many phone numbers I knew.

You could use formatted field in the form for this. A masked field will try to save all content. For such a field you will need the phone numbers as VARCHAR.

1 Like