in message:
and given the time at the moment in the US, thanks fro replying to my call
for help, (it is 12 noon) in adelaide south australia
I'm here just for you Patrick.
I think this should be all you need. Make a backup before beginning.
Also, make sure you set a reference to the DAO object library.
1. Create a new field in the Switchboard Items table called PictureLocation
with a data type of text. You will need to manually fill in the full path to the
pictures for each record.
2. Copy and paste this code *over* your existing FillOptions sub:
'*************Code Start*************
Private Sub FillOptions()
On Error GoTo ErrorPoint
' Code originally used from Microsoft's Switchboard Manager
' and Access 2000 database template wizards.
' Modified by Jeff Conrad - Access Junkie
' © Conrad Systems Development 2005
' Fill in the options for this switchboard page.
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
Dim intOption As Integer
' Hide all the controls except the first one
' Clear all Pictures back to nothing on command buttons
For intOption = 2 To conNumButtons
Me("Option" & intOption).Visible = False
Me("OptionLabel" & intOption).Visible = False
Me("Option" & intOption).Picture = ""
Next intOption
' Now clear the first command button Picture
Me![Option1].Picture = ""
' Open the table of Switchboard Items, and find
' the first item for this Switchboard Page.
Set dbs = CurrentDb()
strSQL = "SELECT * FROM [Switchboard Items]"
strSQL = strSQL & " WHERE [ItemNumber] > 0 AND [SwitchboardID]=" _
& Me![SwitchboardID]
strSQL = strSQL & " ORDER BY [ItemNumber];"
Set rst = dbs.OpenRecordset(strSQL)
' If there are no options for this Switchboard Page,
' display a message. Otherwise, fill the page with the items.
If (rst.EOF) Then
Me![OptionLabel1].Caption = "There are no items to display for " _
& "this switchboard page"
Else
While (Not (rst.EOF))
' Set command button to visible
Me("Option" & rst![ItemNumber]).Visible = True
If IsNull(rst![PictureLocation]) Then
' No Picture indicated
Else
' Picture present
' Set the command button's Picture Property to field value
Me("Option" & rst![ItemNumber]).Picture = rst![PictureLocation]
End If
' Make label visible for this command button
Me("OptionLabel" & rst![ItemNumber]).Visible = True
' Fill label caption with Item Text
Me("OptionLabel" & rst![ItemNumber]).Caption = rst![ItemText]
' Move to next record in the page
rst.MoveNext
Wend
End If
ExitPoint:
On Error Resume Next
' Cleanup Code
rst.Close
Set rst = Nothing
Set dbs = Nothing
Exit Sub
ErrorPoint:
MsgBox "The following error has occurred." _
& vbCr & vbCr & "Error #: " & Err.Number _
& vbCr & vbCr & "Please notify Tech Support of this error." _
& vbCr & vbCr & "Description: " & Err.Description, _
vbCritical, "Unexpected Error Encountered"
Resume ExitPoint
End Sub
'*************Code End*************
3. Compile the code, save and close the form.
Then test after you have some picture paths in the records.
I put this together really quick from some other code just now,
but I think that should cover it. Let me know if I missed something.
Hope that helps,