B
Bruce
My form (frmMain) has a combo box (cboName) for Name. The
record source for frmMain is tblMain. The record source
for cboName is [Name]. The row source is the SQL
statement SELECT qryInstructor.EmployeeID, [Last] & ", " &
[First] AS LastFirst, [First] & " " & [Last] AS FullName
FROM qryInstructor. In query design view, that is a three
column query. The first column is EmployeeID, the second
is Last, First and the third column is First Last. The
second column is visible in the combo box, so that the
users select name from a list in Last, First format. The
reason for the third column in the combo box is that on
the report the names need to appear as, for instance,
Johnny Jones rather than Jones, Johnny. However,
elsewhere in the database names are selected from combo
box lists where they appear in Last, First format. Users
were complaining about the First Last format in just one
place on the form.
For purposes of a report I can concatenate the names, so
that Jones, Johnny will appear on the report as Johnny
Jones. However, in the case explained above the users are
not limited to the list. There is a good reason for that,
but let it suffice to say that when Mary Martin is typed
into the combo box, her name needs to appear on the
report. The report (rptMain) has as its record source
qryMain, which is derived from and has the same fields as
tblMain. Text box txtName on the report has as its record
source the field [Name]. A name selected from cboName on
the form will appear as Jones, Johnny, and the typed name
will appear as Mary Martin, or exactly as typed. In order
to have Johnny appear as Johnny Jones, I tried the
following code in txtName on the report:
=IIf([Forms]![frmMain]![cboName].Column(2)="",[Forms]!
[frmMain]![cboName],[Forms]![frmMain]![cboName].Column(2)).
To sum it up, [cboName].Column(2), or the literal third
column, is Johnny Jones, and [cboName] appears as Jones,
Johnny. However, Mary Martin does not show up at all if
her name is typed in. In fact, the text box (on the
report) is set to be invisible when it contains a null
value, and it is invisible when a name is typed into the
combo box (on the form). Again, remember that her name
does show up when the control source for txtName is the
field [Name] from the report's underlying query. However,
attempts to reference that field from within the
expression have so far failed. References to the field
[Name] in either qryMain or tblMain (e.g. [Tables]!
[tblMain]![Name],) produce a parameter dialog box asking
for Tables.
Sorry this went on for so long. There is just no way to
sum this up in a sentence or two. I feel like I am very
close, but I can't quite get there.
record source for frmMain is tblMain. The record source
for cboName is [Name]. The row source is the SQL
statement SELECT qryInstructor.EmployeeID, [Last] & ", " &
[First] AS LastFirst, [First] & " " & [Last] AS FullName
FROM qryInstructor. In query design view, that is a three
column query. The first column is EmployeeID, the second
is Last, First and the third column is First Last. The
second column is visible in the combo box, so that the
users select name from a list in Last, First format. The
reason for the third column in the combo box is that on
the report the names need to appear as, for instance,
Johnny Jones rather than Jones, Johnny. However,
elsewhere in the database names are selected from combo
box lists where they appear in Last, First format. Users
were complaining about the First Last format in just one
place on the form.
For purposes of a report I can concatenate the names, so
that Jones, Johnny will appear on the report as Johnny
Jones. However, in the case explained above the users are
not limited to the list. There is a good reason for that,
but let it suffice to say that when Mary Martin is typed
into the combo box, her name needs to appear on the
report. The report (rptMain) has as its record source
qryMain, which is derived from and has the same fields as
tblMain. Text box txtName on the report has as its record
source the field [Name]. A name selected from cboName on
the form will appear as Jones, Johnny, and the typed name
will appear as Mary Martin, or exactly as typed. In order
to have Johnny appear as Johnny Jones, I tried the
following code in txtName on the report:
=IIf([Forms]![frmMain]![cboName].Column(2)="",[Forms]!
[frmMain]![cboName],[Forms]![frmMain]![cboName].Column(2)).
To sum it up, [cboName].Column(2), or the literal third
column, is Johnny Jones, and [cboName] appears as Jones,
Johnny. However, Mary Martin does not show up at all if
her name is typed in. In fact, the text box (on the
report) is set to be invisible when it contains a null
value, and it is invisible when a name is typed into the
combo box (on the form). Again, remember that her name
does show up when the control source for txtName is the
field [Name] from the report's underlying query. However,
attempts to reference that field from within the
expression have so far failed. References to the field
[Name] in either qryMain or tblMain (e.g. [Tables]!
[tblMain]![Name],) produce a parameter dialog box asking
for Tables.
Sorry this went on for so long. There is just no way to
sum this up in a sentence or two. I feel like I am very
close, but I can't quite get there.