Actions from combo box

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

Guest

Hi (again) experts

I have a form (Details_Clients_Main) which has a subform (Bookings_Main).
At the moment the subform has a lot of buttons on it to send reports and open
other forms that are related to the booking using Booking_Ref to make sure
that the correct reports are printed and the correct subforms are opened

Basically I would like to remove most of the buttons so it’s not so
cluttered and so I have created a combo box with a list of regular reports
and the names of other forms that I would like to open (linked to the
Booking_Ref on the Details_Clients_Main form) as I read somewhere that this
is possible.

IIs there a way to use only one combo box for different processes – such as
print reports or open sub-forms.

At the moment the combo box (action_selector) has the following names (and
it doesn’t work??)

"Actions":"Print Confirmation":"Print_Card":"Payment_Extras":"Drop_Off"

Actions I want the word “Actions†to be displayed in the box but it does not
do anything else.
Print Confirmation should open a report called Rpt_Confirmation
Print Card should open a report called Rpt_Card
Drop Off should open a form call Drop_Off
Payment Extras should open a form called Bookings_Extras

I will bake loads of cookies for anyone who can help (LoL)

Alison
 
Hi Alison

It won’t work (at the moment) – sorry about that

BUT you CAN get it to work if you separate the headings in the row source
with semi colons at the moment you are using colons. ( ; instead of : )
e.g "Actions";"Print Confirmation";"NEXT WORD"
To get word actions or whichever word you place topmost in the list, as the
default heading in the box use
=[actions_Selector].[ItemData](0)
in the default value. Although cant really see why have you put it on the
list by the way.

Next, basically you can get many actions to run from a combo-box providing
you tell the programme to do them. You need to place code behind the
combo-box and when the text that you have selected equals a certain string of
text in the code it will run a pre-defined action. Hope that makes sense.

So

In the on-click event insert this, or you could put it into the after-update
event or any other event you want to use.

Private Sub action_Selector_Click()
If (Forms!Details_Clients_Main!Bookings_Main.Form!actions_selector =
"Print Confirmation") Then
DoCmd.OpenReport "Rpt_Confirmation", acViewNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acNormal
End If
If (Forms!Details_Clients_Main!Bookings_Main.Form!actions_selector =
"Print_Card") Then
DoCmd.OpenReport "Rpt_Card", acViewNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acNormal
End If
If (Forms!Details_Clients_Main!Bookings_Main.Form!action_selector =
"Drop Off") Then
DoCmd.OpenForm "Drop_Off", acNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acEdit, acNormal
End If
If (Forms!Details_Clients_Main!Bookings_Main.Form!action_selector =
"Payment Extras") Then
DoCmd.OpenForm "Bookings_Extras", acNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acEdit, acNormal
End If
End Sub

Hope this helps

Wayne

PS. When do I get my cakes ??
 
Actually, a LIST BOX with complex selection enabled would be a better
solution. Then you can select as many individual items to perform as you
want, in a single pass.

Wayne-in-Manchester said:
Hi Alison

It won’t work (at the moment) – sorry about that

BUT you CAN get it to work if you separate the headings in the row source
with semi colons at the moment you are using colons. ( ; instead of : )
e.g "Actions";"Print Confirmation";"NEXT WORD"
To get word actions or whichever word you place topmost in the list, as the
default heading in the box use
=[actions_Selector].[ItemData](0)
in the default value. Although cant really see why have you put it on the
list by the way.

Next, basically you can get many actions to run from a combo-box providing
you tell the programme to do them. You need to place code behind the
combo-box and when the text that you have selected equals a certain string of
text in the code it will run a pre-defined action. Hope that makes sense.

So

In the on-click event insert this, or you could put it into the after-update
event or any other event you want to use.

Private Sub action_Selector_Click()
If (Forms!Details_Clients_Main!Bookings_Main.Form!actions_selector =
"Print Confirmation") Then
DoCmd.OpenReport "Rpt_Confirmation", acViewNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acNormal
End If
If (Forms!Details_Clients_Main!Bookings_Main.Form!actions_selector =
"Print_Card") Then
DoCmd.OpenReport "Rpt_Card", acViewNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acNormal
End If
If (Forms!Details_Clients_Main!Bookings_Main.Form!action_selector =
"Drop Off") Then
DoCmd.OpenForm "Drop_Off", acNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acEdit, acNormal
End If
If (Forms!Details_Clients_Main!Bookings_Main.Form!action_selector =
"Payment Extras") Then
DoCmd.OpenForm "Bookings_Extras", acNormal, "",
"[BookingRef]=[Forms]![Details_Clients_Main]![Bookings_Main].[Form]![BknBookingRef]", acEdit, acNormal
End If
End Sub

Hope this helps

Wayne

PS. When do I get my cakes ??





Alison Arulia said:
Hi (again) experts

I have a form (Details_Clients_Main) which has a subform (Bookings_Main).
At the moment the subform has a lot of buttons on it to send reports and open
other forms that are related to the booking using Booking_Ref to make sure
that the correct reports are printed and the correct subforms are opened

Basically I would like to remove most of the buttons so it’s not so
cluttered and so I have created a combo box with a list of regular reports
and the names of other forms that I would like to open (linked to the
Booking_Ref on the Details_Clients_Main form) as I read somewhere that this
is possible.

IIs there a way to use only one combo box for different processes – such as
print reports or open sub-forms.

At the moment the combo box (action_selector) has the following names (and
it doesn’t work??)

"Actions":"Print Confirmation":"Print_Card":"Payment_Extras":"Drop_Off"

Actions I want the word “Actions†to be displayed in the box but it does not
do anything else.
Print Confirmation should open a report called Rpt_Confirmation
Print Card should open a report called Rpt_Card
Drop Off should open a form call Drop_Off
Payment Extras should open a form called Bookings_Extras

I will bake loads of cookies for anyone who can help (LoL)

Alison
 
Back
Top