Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If statements in Visual Basic 1

Status
Not open for further replies.

emilybartholomew

Technical User
Aug 3, 2001
82
US
I am trying to create conditional statements based on the value of a control.

If [Page].Value = "1" Then
performer_page_header.Visible = False
End If

This is supposed to check the value of the control "Page", and if it is 1, the "performer_page_header" should be not visible. I've tried lots of combinations: Me.Page, Me.[Page], Me.Page.Value, etc etc, but nothing works.

Thanks.

 
Hi!

What type of control is Page? Will its value be a number or a string? You might try the if without the quotes around the 1. Normally the statement would read:

If Me!Page.Value = "1" (or 1) Then

One last thought, page may be a reserved word in VBA, you might consider calling the control txtPage or chkPage depending on the type of control it is.

hth
Jeff Bridgham
bridgham@purdue.edu
 
Thanks Jeff-

I'm using [Page] from the automatic footer access provides (as in ="Page " & [Page] & " of " & [Pages]).

Still no luck. I'm using Access 2000. Will that make a difference?
 
Hi!

Okay, I get it now. You will need to make a textbox on your report and set its control source to =Page, you will want to make the box invisible. Now you can reference the value in the textbox in your code.

hth
Jeff Bridgham
bridgham@purdue.edu
 
OK. I've created a textbox called "page_number" and set it's control source = [Page].
My current conditional is:
If Me!page_number.Value = "1" Then
(I also tried Me!page_number.Value = 1)

However I keep getting the error "The expression you entered has no value"
 
Hi!

Here's the code I just used and it worked:

If Text19.Value = "1" Then
Me.PageHeaderSection.Visible = False
End If

I put it in the PageHeaderSection_Format event procedure.

hth
Jeff Bridgham
bridgham@purdue.edu
 
You rock!

Thank you so much.

I was actually putting it in the wrong Event Procedure.

My boss will be very happy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top