Add *Favorites* to a Continuous Form...

In fileDiva there is a master File List that contains anywhere from 200 to 300+ documents.  However, individual Users only access anywhere from 5 to 20 on a daily basis.  While there is the ability to search-as-you-type, it's still annoying to have to keep searching for the same documents over and over again.  Since it's all about the User's experience here's a way to put their Favorites rith the top of the List.
The difficult I do immediately, the impossible takes a little bit longer.
Forms
Tips (Main)
Home
Let your Client customize the form labels
Linking Subforms to an Unbound Control(s) on the Main (Parent) Form
Customize your Main Menu or Switchboard
Auto-Add new child records when adding a new record on the Main (Parent) Form
Simple Bar Chart using Shapes
Simulate a Drop Down box (not a Combo Box) as seen on Web Pages
Implement a Log-On form to control what the User sees
Make Controls resize with a Form
Switch Windows
Assign *Permissions* based on Users Levels
New User Form
Custom Record Selectors
Searching Records
Drill Down (for Continuous Forms)
Highlight Required Controls (End-User Defined)
Private Sub cmdAddToFavorites_Click()
 
    pubProgramImagePath = DLookup("sSetting", "tblSettings", "[sSettingTypeID] = " & 16) & "Star16.png"
 
    If DCount("mfFileID", "tblMyFavorites", "[mfNetworkID] = '" & Environ("UserName") & "' And mfFileID =" & Me.txtFileID) = 0 Then
        strSQL = "INSERT INTO tblMyFavorites ( mfFileID, mfImagePath, mfNetworkID ) " & _
                    "SELECT " & Me.txtFileID & ",'" & pubProgramImagePath & "', '" & Environ("UserName") & "'"
                  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
        intCurrentID = Me.CurrentRecord
        DoCmd.GoToRecord , , acGoTo, intCurrentID
        Me.Requery
    Else
        strSQL = "DELETE *, mfID " & _
                    "FROM tblMyFavorites " & _
                        "WHERE mfID=" & Me.txtID & ""
                  CurrentDb.Execute strSQL, dbFailOnError + dbSeeChanges
        Me.Requery
        DoCmd.GoToControl "txtFocus"
        Me.txtFocus.SelStart = 0
    End If
 
End Sub
1. Create a table named tblMyFavorites and add the fields below...
mfID - PK (Autonumber)
mfFileID - (Number, Long Integer)
mfImagePath - (Text, 255)
mfNetworkID - (Text, 50)
mfTimeStamp - (Date/Time)
2. Place the tblMyFavorites table in the query that is the RecordSource for the continuous form and JOIN via Primary Key (PK( from main table to Foreign Key (FK) in tblMyFavorites.  Then place the below line on the Field: row in the query placing the path to the silver star in the highlighted part; and move to the first field in the query grid and set Sort: to Ascending.
3. Get two images, one of a yellow Star and a silver Star and place in a folder in the same location as the Backend (or you can create one called images).  (My favorite place to go for images is Icon Archive.)

4. Open your continuous form in Design View and place Image Control (name imgFavorites) and Command Button (name cmdAddToFavorites) on your Form of the same size.  Note, the Command Button's Back Style property must be set to Transparent.  Place the Command Button on top of the Image Control.

Set the Control Source of the Image Control to strFavorites (from Step 2).  Copy\paste the lines between Private Sub cmdAddToFavorites_Click() and End Sub into the On_Click event of cmdAddToFavorites.
strFavorites: IIf([mfNetworkID]=getNetworkID(),[mfImagePath],"P:\fdBE\images\StarSilver16.png")
5. All done!  Now when you open the Form you should see all silver stars.  Once a User clicks a star it will turn yellow and move to the top of their list.
If you do not have a Settings table you can type in the complete path including image name after the equal sign.  If you would like to create a Settings table click here.  Just be sure to change the 16 to whatever the PK number is in your table.
This site uses cookies to collect data on usage. By continuing to browse this site you consent to this policy. Find out more here.