Senin, 22 Februari 2021

Re: [MSAccessProfessionals] How to make a form go to a record with a particular ID

The code below can easily be adapted to work on the same form instead of opening another.  You can also try the combo box wizard and choose the third option, "Find a record...".  You'll only see that option if the form is bound to a table though, if memory serves.  The wizard will use a bookmark as well, or at least it used to.


Paul

------ Original Message ------
From: "Dave Williams" <davewillgmale@gmail.com>
Sent: 2/22/2021 4:01:09 PM
Subject: Re: [MSAccessProfessionals] How to make a form go to a record with a particular ID

Jim,

That looks very simple but I don't see the relevance to my problem. I don't want to open another form, which would open at its first record. I just want to change the record already being displayed by my form.

Regards,
Dave

On 22/02/2021 22:36, Jim Wagner wrote:
Dave,

I created this solution a long time ago but it works. 
I have a form with mini subforms that break out tasks sort of like a card in task apps. when i click on the TaskId in one of the suborms a macro is executied

If IsNull([TaskID])
Beep
End If

If Not IsNull([TaskID])

OpenForm
form Name "name of the form goes here"
view  Form
Where Condition  =="[TaskID]=" & [TaskID]
 windows mode Normal

End if

OnError
Go to Next
Macro Name
Requery
Control Name

hope that gives you some ideas or an approach

good luck

Jim Wagner



From: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io> on behalf of Dave Williams <davewillgmale@gmail.com>
Sent: Monday, February 22, 2021 2:44 PM
To: MSAccessProfessionals@groups.io <MSAccessProfessionals@groups.io>
Subject: [MSAccessProfessionals] How to make a form go to a record with a particular ID
 
I have created a form to display photos from various folders on my PC. The record source is a table as follows:
Name: Photos
Field Name, Data Type
ImageID, Autonumber
Folder, Text
Photo, Text
It contains 100 records e.g.
38, 14/07/2018, 13880718, PICT0001.JPG

This works fine when using the normal navigation buttons, but as there are so many records I have added a list box containing the years, each with the appropriate starting record ID, contained in a table as follows:

Name: FirstPhotoOfYear
Field Name, Data Type
Year, Text
1st photo ID, Number

5 records e.g.
2018, 38

So when I select 2018 in the list box, I want to make the form show the record with ID = 38. I thought it might help to add a text box (called Text13) on the form that shows the ID number produced by the list box (called List11). This shows the ID fine, using a suitable expression as its control source.
In code which operates when the list box is updated, I first use Text13.Requery, followed by DoCmd.FindRecord but without success. I don't know how to make it search just the ID field, or even if it's found anything, as the form does not change to a new record.

I await suggestions.
.








Tidak ada komentar:

Posting Komentar