using unbound comboboxes

M

Mark Kubicki

If someone could simply tell me if I'm in the right direction

- i have a table [ReportList] with 2 fields: [ReportCommonName] and
[ReportName]
- on a form, i have a combobox: cboReportSelect with [ReportCommonName] as
its datasource
- the user's selection in the cbo will determine what [ReportName] will be
used in in a "print report" command

- i think i need to set up a global variable [vReportName] and assign to it
the value of the [ReportName] where [ReportCommonName] = cboReportSelect
- i am trying to use this line of code:
vReportName = DLookup("[ReportName]", "ReportList",
"[ReportCommonName] = cboReportSelect.value")

(but am not having much luck)

- i would then use the variable in a line of code something like this:
Dim blRet As Boolean
blRet = ConvertReportToPDF("vReportName", vbNullString, "temp.pdf",
False, True, 0, "", "", 0, 0)

thanks in advance,
mark
 
L

Linq Adams via AccessMonster.com

Most people here will tell you that Global variables are best not used unless
absolutely necessary, and it certainly isn't needed here, nor is using
DLookUp().

Set up your combobox using the Wizard.
Select ReportList as your source
Move over ReportCommonName field
Move over ReportName field

Now all you have to do, probably in the cboReportSelect_AfterUpdate event,
is refer to the second column of the combobox which, since they're zero-based,
is called column 1

Private Sub cboReportSelect_AfterUpdate()
ConvertReportToPDF(Me.cboReportSelect.Coulumn(1), vbNullString,
"temp.pdf", False, True, 0, "", "", 0, 0)
End Sub

ReportCommonName is the field you'll see in the first column of your combobox.
You can hide the second column if you don't want to see it. When a selection
is made using the ReportCommonName, Me.cboReportSelect.Coulumn(1) will hold
the actual name of the report, ReportName.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top