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
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...
mfFileID - (Number, Long Integer)
mfImagePath - (Text, 255)
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.