Thanks for the assistance Graham, here is some of the coding in my CNC
Machine Input form, it has the list box, a cancel & a print button.
The list box is generated from the main table query as follows:
SELECT [Main Table Query].[Machine Description] FROM [Main Table Query]
Like I said, the list box will show different machines, but I cant select
one specific machine from the list & print/view the form for that machine.
The machine field is in a related table called "Machine Data Table," but
that shouldn't matter, they show on the list box.
CODE:
Private Sub CNCMachine_Lstbox_Click()
Me.bntPrint.Enabled = (Not IsNull(Me.CNCMachine_Lstbox))
End Sub
***********************************************
Private Sub bntPrint_Click()
DoCmd.OpenForm "CNC Booklet", acNormal, "Machine Description=" &
Me.CNCMachine_Lstbox
DoCmd.Close acForm, "input form", acSaveNo
DoCmd.Close acForm, "CNC Machine Input", acSaveNo
End Sub
Graham R Seach said:
You'll have to show us how you're calling the OpenReport method, what
criteria you're using, and how that maps to the underlying table/query.
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
Forgot all about the "Enable" on/off stuff, got that to work but still
can't
get just the list box's highlighted machine report to print. I use the
same
8 digit part number & 4 digit operation when I test the code, when the
form
with the list box appears there are 2 machine options, I highlight one
but
it
still displays both forms when I hit the "Display" button. I'm trying
to
get
the listbox coding to work with the docmd.openform first, don't want to
waste
a forest of paper.
Should I have something else in the "Click" procedure for the list box
to
point to the highlighted machine?
I'm still plugging.
:
I'd suggest that the preferred method would be to use a Print command
button, which is enabled when, and only when, a valid selection is
made
in
the ListBox.
1. Disable the command button (Enabled=False).
2. In the ListBox's Click event:
Me.cmdPrint.Enabled = (Not IsNull(Me.lstListBox))
3. In the Print command button's Click event:
DoCmd.OpenReport strReportName, , , , "MachineID = " &
Me.lstListBox
Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------
Have a form with a list box come up when a query has more than one
record,
the list box shows the possible CNC machines that the process can be
run
on.
I want the user to select the machine from the list and have that
record
printed. Do I write code for a double click on machine selected?
Have
them
highlight the machine in the list & have a "PRINT" button? The
latter
was
my
thought, a "PRINT" & a "CANCEL" button. How would the call out look
for
the
print command: Docmd.OpenReport.......? Need to look for the
listbox
result,
right!?
Thanks