Forms

G

Guest

I have two different forms, each has the same set of controls for entering
payment information. One control is an option box to select payment method -
cash, check, or credit. The other is a control to enter a check number. The
way it is set up is that the Check No control is not visible, and the OnClick
event of the payment method option box checks if the payment method is
"Check", and if it is makes the Check No control visible, moves focus to the
Check No control and changes the label of the Check No control to Red & bold.
The code is the same in both forms :

If Me.txtPmtMethod = 2 Then
Me.txtCheckNo.Visible = True
Me.txtCheckNo.Enabled = True
Me.txtCheckNo.Locked = False
Me.lblCheckNo.ForeColor = 255
Me.lblCheckNo.FontSize = 10
Me.lblCheckNo.FontWeight = Bold
Me.txtCheckNo.SetFocus
Else
Me.txtCheckNo.Visible = False
Me.txtCheckNo.Enabled = False
Me.txtCheckNo.Locked = True
Me.lblCheckNo.ForeColor = 0
Me.lblCheckNo.FontSize = 8
Me.lblCheckNo.FontWeight = normal
End If

One of the forms works fine. In the other one, when I select Check as
payment method, I get an error message:
Complie Error:
Variable not defined

And the debugger points to the line of code:
Me.lblCheckNo.FontWeight = Bold
With "Bold" highlighted.

If I comment that line of code, I get the same error and the debugger shows:
Me.lblCheckNo.FontWeight = normal
With "normal" highlighted.

Again, the two controls on both forms are identical, with the same
properties, and the code was cut and paste from the first form to the second.

It is the second form that is giving the errors.

Any Ideas?? Thanks -- Garry Gross
 
S

Steve Schapel

Garry,

I have no off-hand explanation for this behaviour. I have never used
this syntax, I always use the Visual Basic constant for Bold (700) or
Normal (400), e.g....
Me.lblCheckNo.FontWeight = 700
 
D

Douglas J. Steele

Actually, the explanation is simple: the FontWeight property only accepts
numeric values!
 
S

Steve Schapel

Hi Doug. Actually, the thing we are trying to explain is that Garry has
a form where he has the FontWeight property successfully accepting a
value of Bold and Normal.
 
G

Guest

Thanks, using 700 for Bold and 400 for normal works. BUT, as Steve says
below, Why did using Bold & Normal instead of using the numbers work in the
first form? In fact when I typed in the statement, I typed "bold" and the VB
editor automatically changed it to "Bold". However it did not change the n
in normal to a Cap.

Garry
 
D

Douglas J. Steele

The only thing that makes sense is that you had variables (or constants)
defined with the values 400 and 700. As far as I can tell, there aren't any
intrinsic constants available for this in Access, like there are for most
other properties.
 
G

Guest

I just did a search for bold in the forms code and in the one module I have
for public functions, subs, and constants. Found nothing. Also, in the form
that using Bold works, I noticed that in the code behind the form, I also
have 3 instances of the following line of code:
Me.lblSalesTax.FontWeight = extrabold
And they all work fine.

Garry
 
D

Douglas J. Steele

What do you get if you go to the Immediate Window (Ctrl-G), type ?Bold and
hit enter?
 
S

Steve Schapel

Garry,

If you don't have 'Option Explicit' declared at the top of the form's
module, the code will probably run without throwing the error... but the
font won't change. Is your font actually changing to ExtraBold via this
code?
 
G

Guest

BINGO! That's the reason. One form had Option Explicit set, the other did
not. I guess I wasn't really looking close enough at the "boldness" on the
form that seemed to work.
Thanks for all your effort. -- Garry Gross
 

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

Similar Threads


Top