switchboard

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am using the default switchboard as the men system for a database.

What I would like to do is change the embedded picture for each command
button depending on what the item attached to the button is.

I have viewed the structure of the switchboard tables and see that i could
posibly add an extra field which might be perhaps a jgp file etc, Can we
refer to the field so that the pictures (icons) atached to a specific command
button changes depending upon what sub menu has been selected??
 
in message:
I am using the default switchboard as the men system for a database.

What I would like to do is change the embedded picture for each command
button depending on what the item attached to the button is.

I have viewed the structure of the switchboard tables and see that I could
possibly add an extra field which might be perhaps a jgp file etc, Can we
refer to the field so that the pictures (icons) attached to a specific command
button changes depending upon what sub menu has been selected??

Hi Patrick,

My Advanced Switchboard Manager Add-in does exactly this.
(Ohh sure, spoil the surprise now :-) )

Each command button can be given it's own picture if desired.

I've also done this before manually using a file path field just as
you described. Which Access version are you using? Do you
mind using DAO code for the Switchboard? I have some DAO
code to accomplish your goal.
 
mmmm

I am using 2002....
and yes I assumed I had to have code in the background so that every time
anew sub menu was opened the associated picture attached to the button would
change

and.... yes please, all assistance gratefully accepted
 
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
 
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,
 
my only problem now is that the buttons and captions stay permanent on the
screen, they dont go invisible when they should

cant seem to find the problem
--
Regards


Patrick Stubbin


Jeff Conrad said:
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,
 
ignore that... fixed


thanks muchly
--
Regards


Patrick Stubbin


Jeff Conrad said:
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,
 
Back
Top