codeing in reports

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

Guest

IS there some reason why vba doesnt work? My code is
If Me.renupgrd <> "r" Then
Me.txtrenupgrdas = "Upgraded to:"
Me.txttitle = Me.mg & " Upgrade"
Else
Me.txttitle = Me.mg & " Renewal"
Me.txtrenupgrdas = "Renewed as:"
End If

It highlights 'me.renupgrd' saying 'you entered an expresion that has no
value' But it does have a value. The control is even on the form as it first
of all said 'Microsoft Access cannont find the control'

Am I missing something here?

Thanks in advance for your help

James
 
James said:
IS there some reason why vba doesnt work? My code is
If Me.renupgrd <> "r" Then
Me.txtrenupgrdas = "Upgraded to:"
Me.txttitle = Me.mg & " Upgrade"
Else
Me.txttitle = Me.mg & " Renewal"
Me.txtrenupgrdas = "Renewed as:"
End If

It highlights 'me.renupgrd' saying 'you entered an expresion that has no
value' But it does have a value. The control is even on the form as it first
of all said 'Microsoft Access cannont find the control'

Am I missing something here?


Where is the code?
Where are the text boxes?

The control's value may not exist during the initial form
processing. E.g. If its in the Open event, move it to the
Load event.
 
Its in the On Open event, there isnt a On Load event.

I put it in On Activate and it is now saying "You cannot assign a value to
that control" Highlighting Me.renupgrd. Its not trying to assing a value
though its using it in a If statement.
 
Just noticed that even though it says it cant assign a value to the text box,
it still does. It stopes the code after but it does work I don't get it? Why
would it stop with an error after it has done what it is supposed to do?

James
 
Ok just realised the problem. The text boxes have to be Unbound before the
code is run for some odd reason. I moved the code to On Activate and set all
the boxes undbound in design view and it works fine now.

Many thanks for your help.
 
James said:
Ok just realised the problem. The text boxes have to be Unbound before the
code is run for some odd reason. I moved the code to On Activate and set all
the boxes undbound in design view and it works fine now.


Sorry, my mind was thinking form instead of report.

Anyway, yes, the controls must be unbound if you're going to
assign their value in code. However, you should use the
Format event of the section containing the controls, not the
Activate event. The Activate event does not fire when the
report is printed, it only executes when the report is
previewed.
 
Back
Top