Connecting Tech Pros Worldwide Forums | Help | Site Map

appending prefix to a report field

Zenon
Guest
 
Posts: n/a
#1: Nov 13 '05
I am attempting to append a string prefix to a report field which is
based on a query result. I want the user to be able click a checkbox
on the form which opens the report to determine whether the string is
appended or not. I see that this can be done in the properties of the
field, but I cannot figure out if it can be done with VB code. Since
it needs to be an option, I cannot do it in the properties (at least
as far as I know). Is this possible and if so, how is it done?
Thanks in advance.

Allen Browne
Guest
 
Posts: n/a
#2: Nov 13 '05

re: appending prefix to a report field


Set the Control Source of the text box on your report to something like
this:
=IIf([Forms].[Form1].[Checkbox1]=True, "My prefix ", Null) & [Field2])

Note that you should also change the Name property of the text box. If it
has the same name as the Field but is bound to something else, Access gets
confused.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Zenon" <zenonk@comcast.net> wrote in message
news:b1483a18.0407311711.318c285b@posting.google.c om...[color=blue]
> I am attempting to append a string prefix to a report field which is
> based on a query result. I want the user to be able click a checkbox
> on the form which opens the report to determine whether the string is
> appended or not. I see that this can be done in the properties of the
> field, but I cannot figure out if it can be done with VB code. Since
> it needs to be an option, I cannot do it in the properties (at least
> as far as I know). Is this possible and if so, how is it done?
> Thanks in advance.[/color]


Zenon
Guest
 
Posts: n/a
#3: Nov 13 '05

re: appending prefix to a report field


Thanks for the help, however, I still can't get this to work. In my
test case, I have a form cleverly called TestForm. On it is a
checkbox called Check6, and a button which opens a report called
ReportTest based on a query called Query1. I have renamed Field1 on
the report to FieldOneName, and have entered the following formula in
it's control source. At this time, I'm not even worried about adding
the prefix but just getting the IIf statement to work. Do you see
what I'm doing wrong?

=IIf([Forms]![TestForm]![Check6]=True,([FieldOneName]="Checked"),([FieldOneName]="Not
Checked"))

"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message news:<410ca0cc$0$16325$5a62ac22@per-qv1-newsreader-01.iinet.net.au>...[color=blue]
> Set the Control Source of the text box on your report to something like
> this:
> =IIf([Forms].[Form1].[Checkbox1]=True, "My prefix ", Null) & [Field2])
>
> Note that you should also change the Name property of the text box. If it
> has the same name as the Field but is bound to something else, Access gets
> confused.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Zenon" <zenonk@comcast.net> wrote in message
> news:b1483a18.0407311711.318c285b@posting.google.c om...[color=green]
> > I am attempting to append a string prefix to a report field which is
> > based on a query result. I want the user to be able click a checkbox
> > on the form which opens the report to determine whether the string is
> > appended or not. I see that this can be done in the properties of the
> > field, but I cannot figure out if it can be done with VB code. Since
> > it needs to be an option, I cannot do it in the properties (at least
> > as far as I know). Is this possible and if so, how is it done?
> > Thanks in advance.[/color][/color]
Allen Browne
Guest
 
Posts: n/a
#4: Nov 13 '05

re: appending prefix to a report field


Try:
=IIf([Forms]![TestForm]![Check6]=True,"Checked","Not Checked")

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Zenon" <zenonk@comcast.net> wrote in message
news:b1483a18.0408030549.481bc9ed@posting.google.c om...[color=blue]
> Thanks for the help, however, I still can't get this to work. In my
> test case, I have a form cleverly called TestForm. On it is a
> checkbox called Check6, and a button which opens a report called
> ReportTest based on a query called Query1. I have renamed Field1 on
> the report to FieldOneName, and have entered the following formula in
> it's control source. At this time, I'm not even worried about adding
> the prefix but just getting the IIf statement to work. Do you see
> what I'm doing wrong?
>
>[/color]
=IIf([Forms]![TestForm]![Check6]=True,([FieldOneName]="Checked"),([FieldOneN
ame]="Not[color=blue]
> Checked"))
>
> "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message[/color]
news:<410ca0cc$0$16325$5a62ac22@per-qv1-newsreader-01.iinet.net.au>...[color=blue][color=green]
> > Set the Control Source of the text box on your report to something like
> > this:
> > =IIf([Forms].[Form1].[Checkbox1]=True, "My prefix ", Null) &[/color][/color]
[Field2])[color=blue][color=green]
> >
> > Note that you should also change the Name property of the text box. If[/color][/color]
it[color=blue][color=green]
> > has the same name as the Field but is bound to something else, Access[/color][/color]
gets[color=blue][color=green]
> > confused.
> >
> >
> > "Zenon" <zenonk@comcast.net> wrote in message
> > news:b1483a18.0407311711.318c285b@posting.google.c om...[color=darkred]
> > > I am attempting to append a string prefix to a report field which is
> > > based on a query result. I want the user to be able click a checkbox
> > > on the form which opens the report to determine whether the string is
> > > appended or not. I see that this can be done in the properties of the
> > > field, but I cannot figure out if it can be done with VB code. Since
> > > it needs to be an option, I cannot do it in the properties (at least
> > > as far as I know). Is this possible and if so, how is it done?
> > > Thanks in advance.[/color][/color][/color]


Zenon
Guest
 
Posts: n/a
#5: Nov 13 '05

re: appending prefix to a report field


Beautiful, thanks very much. This expression worked perfectly.

=IIf([Forms]![TestForm]![Check6]=True,"Checked " & [Field1],"Not Checked")

"Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message news:<410fa102$0$16331$5a62ac22@per-qv1-newsreader-01.iinet.net.au>...[color=blue]
> Try:
> =IIf([Forms]![TestForm]![Check6]=True,"Checked","Not Checked")
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Zenon" <zenonk@comcast.net> wrote in message
> news:b1483a18.0408030549.481bc9ed@posting.google.c om...[color=green]
> > Thanks for the help, however, I still can't get this to work. In my
> > test case, I have a form cleverly called TestForm. On it is a
> > checkbox called Check6, and a button which opens a report called
> > ReportTest based on a query called Query1. I have renamed Field1 on
> > the report to FieldOneName, and have entered the following formula in
> > it's control source. At this time, I'm not even worried about adding
> > the prefix but just getting the IIf statement to work. Do you see
> > what I'm doing wrong?
> >
> >[/color]
> =IIf([Forms]![TestForm]![Check6]=True,([FieldOneName]="Checked"),([FieldOneN
> ame]="Not[color=green]
> > Checked"))
> >
> > "Allen Browne" <AllenBrowne@SeeSig.Invalid> wrote in message[/color]
> news:<410ca0cc$0$16325$5a62ac22@per-qv1-newsreader-01.iinet.net.au>...[color=green][color=darkred]
> > > Set the Control Source of the text box on your report to something like
> > > this:
> > > =IIf([Forms].[Form1].[Checkbox1]=True, "My prefix ", Null) &[/color][/color]
> [Field2])[color=green][color=darkred]
> > >
> > > Note that you should also change the Name property of the text box. If[/color][/color]
> it[color=green][color=darkred]
> > > has the same name as the Field but is bound to something else, Access[/color][/color]
> gets[color=green][color=darkred]
> > > confused.
> > >
> > >
> > > "Zenon" <zenonk@comcast.net> wrote in message
> > > news:b1483a18.0407311711.318c285b@posting.google.c om...
> > > > I am attempting to append a string prefix to a report field which is
> > > > based on a query result. I want the user to be able click a checkbox
> > > > on the form which opens the report to determine whether the string is
> > > > appended or not. I see that this can be done in the properties of the
> > > > field, but I cannot figure out if it can be done with VB code. Since
> > > > it needs to be an option, I cannot do it in the properties (at least
> > > > as far as I know). Is this possible and if so, how is it done?
> > > > Thanks in advance.[/color][/color][/color]
Closed Thread